Dot net Projects

Dot net Projects Lets start learning .net language..

FLV CONVERTER-------------------------SOURCE CODE:---------------------->form1:    ---------Imports System.IOPublic Clas...
09/04/2015

FLV CONVERTER
-------------------------
SOURCE CODE:
---------------------
->form1:
---------
Imports System.IO
Public Class Form1
Dim proc As New Process 'make it global so dat we can kill it from outside
Function startConversion()
Control.CheckForIllegalCrossThreadCalls = False
Dim input As String = Me.dlgOpen.FileName
Dim output As String = Me.dlgSave.FileName
Dim exepath As String = Application.StartupPath + "\bin\ffmpeg.exe"
Dim quality As Integer = TrackBar1.Value * 2

Dim startinfo As New System.Diagnostics.ProcessStartInfo
Dim sr As StreamReader
Dim cmd As String = " -i """ + input + """ -ar 22050 -qscale " & quality & " -y """ + output + """" 'ffmpeg commands -y replace

Dim ffmpegOutput As String

' all parameters required to run the process
startinfo.FileName = exepath
startinfo.Arguments = cmd
startinfo.UseShellExecute = False
startinfo.WindowStyle = ProcessWindowStyle.Hidden
startinfo.RedirectStandardError = True
startinfo.RedirectStandardOutput = True
startinfo.CreateNoWindow = True
proc.StartInfo = startinfo
proc.Start() ' start the process
Me.lblInfo.Text = "Conversion in progress... Please wait..."
sr = proc.StandardError 'standard error is used by ffmpeg
Me.btnStart.Enabled = False
Do
If BackgroundWorker1.CancellationPending Then 'check if a cancellation request was made
Exit Function
End If
ffmpegOutput = sr.ReadLine
Me.txtProgress.Text = ffmpegOutput
Loop Until proc.HasExited And ffmpegOutput = Nothing Or ffmpegOutput = ""

Me.txtProgress.Text = "Finished !"
Me.lblInfo.Text = "Completed!"
MsgBox("Completed!", MsgBoxStyle.Exclamation)
Me.btnStart.Enabled = True
Return 0
End Function
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
If txtOpen.Text = "" Or txtOpen.Text dlgOpen.FileName Then
MsgBox("Select a file to convert", MsgBoxStyle.Information, "Select a file")
Exit Sub
ElseIf txtSave.Text = "" Or txtSave.Text dlgSave.FileName Then
MsgBox("Select your output filename", MsgBoxStyle.Information, "Select a file")
Exit Sub
End If
BackgroundWorker1.RunWorkerAsync()
End Sub

Private Sub dlgSave_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles dlgSave.FileOk
dlgSave.OverwritePrompt = True
dlgSave.DereferenceLinks = True
dlgSave.CreatePrompt = True
dlgSave.DefaultExt = ".flv"
txtSave.Text = dlgSave.FileName
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
dlgSave.ShowDialog()
End Sub

Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
dlgOpen.ShowDialog()
End Sub

Private Sub dlgOpen_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles dlgOpen.FileOk
dlgOpen.CheckFileExists = True
txtOpen.Text = dlgOpen.FileName

End Sub

Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
On Error GoTo handle
BackgroundWorker1.CancelAsync()
If btnStart.Enabled = False Then
lblInfo.Text = ("Conversion Canceled!")
MsgBox("Conversion has been cancelled!", MsgBoxStyle.Exclamation)
btnStart.Enabled = True
Else
MsgBox("Start conversion first", MsgBoxStyle.Critical)
End If

proc.Kill()
handle:
Exit Sub
End Sub

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
startConversion()
End Sub

Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
MsgBox("Created by Tunde Olabenjo" & vbCrLf & "[email protected]", MsgBoxStyle.Question, "About Video Flash Converter")
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub

Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click

End Sub

Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll

End Sub
End Class

IMAGE CARTOONIZER-----------------------------SOURCE CODE:----------------------->cartoonizer_form    ------------------...
09/04/2015

IMAGE CARTOONIZER
-----------------------------
SOURCE CODE:
----------------------
->cartoonizer_form
---------------------
Imports System.Drawing
Imports System.Windows.Forms

Public Class CartoonizerForm

Private WithEvents FX As New Effects
'Private WithEvents sk As sketch
Private mBitmap As Bitmap
Private mBitmapFileName As String

Private SigmaIntensity As Single
Private SigmaSpatial As Single

Private m_PanStartPoint As New Point

"Pre Effect Panel"

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbPreEffect.SelectedIndexChanged
UpdatePreEffectGroupBoxSize()
pnExposure.Visible = (cbPreEffect.SelectedIndex = 2)
pnBCS.Visible = (cbPreEffect.SelectedIndex = 3)
UpdatePreEffectLabels()
End Sub

Private Sub tbExposure_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbExposure.Scroll
UpdatePreEffectLabels()
End Sub

Private Sub tbBrightness_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbBrightness.Scroll
UpdatePreEffectLabels()
End Sub

Private Sub tbContrast_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbContrast.Scroll
UpdatePreEffectLabels()
End Sub

Private Sub tbSaturation_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbSaturation.Scroll
UpdatePreEffectLabels()
End Sub

Private Sub UpdatePreEffectLabels()
lbExposure.Text = String.Format("Exposure: {0}", tbExposure.Value)
lbExposure.Refresh()
lbBrightness.Text = String.Format("Brightness: {0} %", CInt(200 * (tbBrightness.Value / tbBrightness.Maximum)))
lbBrightness.Refresh()
lbContrast.Text = String.Format("Contrast: {0} %", tbContrast.Value)
lbContrast.Refresh()
lbSaturation.Text = String.Format("Saturation: {0} %", CInt(200 * (tbSaturation.Value / tbSaturation.Maximum)))
lbSaturation.Refresh()
End Sub

Private Sub UpdatePreEffectGroupBoxSize()
Dim width As Integer = 209
Select Case cbPreEffect.SelectedIndex
Case 0, 1
gbPreEffect.Size = New Size(width, 80)
Case 2
gbPreEffect.Size = New Size(width, 135)
Case 3
gbPreEffect.Size = New Size(width, 218)
End Select
End Sub

Region

"Default Values"

Private Sub SetDefaults()
cbPreEffect.SelectedIndex = 0 'None
cbColorMode.SelectedIndex = 1 'LAB
cbIntensityMode.SelectedIndex = 1 'Gaussian2
cbContourMethod.SelectedIndex = 0 'Sobel
SigmaIntensityChange()
SigmaSpatialChange()
UpdatePreEffectLabels()
UpdateBilateralLabels()
UpdateContourLabels()
UpdateLumSegLabels()
End Sub

Region

"Form Events"

Private Sub CartoonizerForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SetDefaults()
End Sub

Region

"Bilateral Panel"

Private Sub tbIterations_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbIterations.Scroll
UpdateBilateralLabels()
End Sub

Private Sub tbSpatialSigma_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbSpatialSigma.Scroll
UpdateBilateralLabels()
SigmaSpatialChange()
End Sub

Private Sub tbSpatialIntensity_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbSpatialIntensity.Scroll
UpdateBilateralLabels()
SigmaIntensityChange()
End Sub

Private Sub tbRadius_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbRadius.Scroll
UpdateBilateralLabels()
SigmaSpatialChange()
End Sub

Private Sub cbIntensityMode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbIntensityMode.SelectedIndexChanged
UpdateBilateralLabels()
SigmaIntensityChange()
End Sub

Private Sub SigmaIntensityChange()
Dim myBM As New Bitmap(pbIntensity.Width, pbIntensity.Height)
FX.zPreview_Intensity(myBM, tbSpatialIntensity.Value / 10000, cbIntensityMode.SelectedIndex)
pbIntensity.Image = myBM
pbIntensity.Refresh()
End Sub

Private Sub SigmaSpatialChange()
Dim myBM As New Bitmap(pbSpatial.Width, pbSpatial.Height)
FX.zPreview_Spatial(myBM, tbRadius.Value, tbSpatialSigma.Value / 10)
pbSpatial.Image = myBM
pbSpatial.Refresh()
End Sub

Private Sub UpdateBilateralLabels()
lbRadius.Text = String.Format("Radius (HalfLate): {0}", tbRadius.Value)
lbRadius.Refresh()
lbSpatialIntensity.Text = String.Format("Spatial Intensity: {0}", tbSpatialIntensity.Value / 1000)
lbSpatialIntensity.Refresh()
lbSpatialSigma.Text = String.Format("Spatial Sigma: {0}", tbSpatialSigma.Value / 10)
lbSpatialSigma.Refresh()
lbIterations.Text = String.Format("Iterations: {0}", tbIterations.Value)
lbIterations.Refresh()
End Sub

Region

"Contour Panel"

Private Sub cbContourMethod_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbContourMethod.SelectedIndexChanged
pnThreshold.Visible = (cbContourMethod.SelectedIndex = 1)
pnLumHue.Visible = (cbContourMethod.SelectedIndex = 0)
UpdateContourLabels()
End Sub

Private Sub tbContourAmount_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbContourAmount.Scroll
UpdateContourLabels()
End Sub

Private Sub tbLumHue_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbLumHue.Scroll
UpdateContourLabels()
End Sub

Private Sub tbContourThreshold_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbContourThreshold.Scroll
UpdateContourLabels()
End Sub

Private Sub UpdateContourLabels()
lbContourAmount.Text = String.Format("Contour Amount: {0}", tbContourAmount.Value)
lbContourAmount.Refresh()
lbLumHue.Text = String.Format("Based On {0}% L {1}% AB :", tbLumHue.Value, 100 - tbLumHue.Value)
lbLumHue.Refresh()
lbContourThreshold.Text = String.Format("Threshold: {0}", tbContourThreshold.Value / 1000)
lbContourThreshold.Refresh()
End Sub

Region

"Luminance Segmentation Panel"

Private Sub tbSegments_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbSegments.Scroll
UpdateLumSegLabels()
End Sub

Private Sub tbPresence_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbPresence.Scroll
UpdateLumSegLabels()
End Sub

Private Sub UpdateLumSegLabels()
lbSegments.Text = String.Format("Segments: {0}", tbSegments.Value)
lbSegments.Refresh()
lbPresence.Text = String.Format("Presence: {0}%", tbPresence.Value)
lbPresence.Refresh()
End Sub

Region

"Progress Bar Events"

Private Sub FX_PercDONE(ByVal Filter As String, ByVal PercValue As Single, ByVal CurrIteration As Long) Handles FX.PercDONE
pbCartoonize.Value = CInt(PercValue * 100)
pbCartoonize.Refresh()
Application.DoEvents()
If PercValue > 0 Then
pbCartoonize.CreateGraphics().DrawString(String.Format("{0} {1} {2}%", Filter, CurrIteration, pbCartoonize.Value.ToString()), New Font("Arial", CSng(8.25), FontStyle.Regular), Brushes.Black, New PointF(10, pbCartoonize.Height / 2 - 7))
End If
End Sub

Region

"Load/Save Bitmap"

Private Sub LoadBitmap()
Dim bm As New Bitmap(mBitmapFileName)
mBitmap = New Bitmap(bm.Width, bm.Height, Imaging.PixelFormat.Format24bppRgb)
mBitmap.SetResolution(bm.HorizontalResolution, bm.VerticalResolution)
Dim g As Graphics = Graphics.FromImage(mBitmap)
g.DrawImage(bm, 0, 0)
g.Dispose()
bm.Dispose()
End Sub

Private Sub btBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btBrowse.Click
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
mBitmapFileName = OpenFileDialog1.FileName
tbImage.Text = mBitmapFileName
tbImage.Refresh()
LoadBitmap()
PictureBox1.Image = mBitmap
PictureBox1.Refresh()
End If
End Sub

Private Sub btSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSave.Click
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image.Save(SaveFileDialog1.FileName)
End If
End Sub

Region

"Cartoonize"

Private Sub btCartoonize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btCartoonize.Click

Dim myBitMap As Bitmap = mBitmap.Clone

PictureBox1.Image = myBitMap
PictureBox1.Refresh()
Cartoonize(PictureBox1.Image)
End Sub

Private Sub DoPreEffect()
Select Case cbPreEffect.SelectedIndex
Case 0
Case 1
FX.MagneKleverHistogramEQU(0.3)
Case 2
FX.MagneKleverExposure(tbExposure.Value)
Case 3
FX.MagneKleverBCS(tbBrightness.Value, tbContrast.Value, tbSaturation.Value)
End Select
End Sub

Private Sub DoContour()
If tbContourAmount.Value > 0 Then
Select Case cbContourMethod.SelectedIndex
Case 0
FX.zEFF_ContourBySobel(tbContourAmount.Value, tbLumHue.Value / 100)
Case 1
FX.zEFF_ContourBySobel2(tbContourAmount.Value, tbLumHue.Value / 100)
End Select
End If
End Sub

Private Sub ApplyContour()
If tbContourAmount.Value > 0 Then
FX.zEFF_Contour_Apply()
End If
End Sub

Private Sub DoBilateral()
FX.zEFF_BilateralFilter(tbRadius.Value, tbIterations.Value, cbIntensityMode.SelectedIndex, cbColorMode.SelectedIndex = 0)
End Sub

Private Sub DoQuantizeLuminance()
FX.zEFF_QuantizeLuminance(tbSegments.Value, tbPresence.Value / 100, tbRadius.Value, False)
End Sub

Private Sub InitDomains()
FX.zInit_IntensityDomain(tbSpatialIntensity.Value / 10000, cbIntensityMode.SelectedIndex)
FX.zInit_SpatialDomain(tbSpatialSigma.Value / 100)
End Sub

Public Sub Cartoonize(ByRef bm As Bitmap)
FX.zSet_Source(bm)
DoPreEffect()
'Uncomment this if you want to call this without the UI
'InitDomains
DoBilateral()
DoContour()
DoQuantizeLuminance()
ApplyContour()

FX.zGet_Effect(bm)
PictureBox1.Image = bm
PictureBox1.Refresh()
FX_PercDONE("", 0, 0)
End Sub

Region

' "Sketch"

' Private Sub Sketch(ByVal bm As Bitmap)
' Dim S As String
' Dim S2 As String

' Dim SPath As String

' Do
' FX_PercDONE("Sketching... ", 0, 1)

' FX.zSet_Source(bm)
' 'SK.SetSource PIC1.Image.Handle

' 'FX.zEFF_MedianFilter 1, 1
' If chDirectional Then
' FX.zEFF_BilateralFilterDirectional(N, ITER, oRGB)
' Else
' FX.zEFF_BilateralFilter(N, ITER, oRGB)
' End If

' FX.zGet_Effect(bm)

' SK.SetSource(bm)

' SK.SetSourceToMIX(bm)
' SK.Sketch()
' SK.MIX(Val(tCONT))
' SK.GetEffect(bm)

' Loop While S ""

' FX_PercDONE("Sketching... ", 1, 1)
' End Sub

' Region

"Image Panning"

Private Sub CartoonizerForm_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
Cursor = Cursors.Hand
m_PanStartPoint = New Point(e.X, e.Y)
End Sub

Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Cursor = Cursors.Default
End Sub

Private Sub CartoonizerForm_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
pbCartoonize.Focus()
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim DeltaX As Integer = (m_PanStartPoint.X - e.X)
Dim DeltaY As Integer = (m_PanStartPoint.Y - e.Y)
pnPic.AutoScrollPosition = New Drawing.Point((DeltaX - pnPic.AutoScrollPosition.X), (DeltaY - pnPic.AutoScrollPosition.Y))
End If
End Sub

Private Sub CartoonizerForm_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
Dim newWidth As Integer
Dim newHeight As Integer

If e.Delta > 0 Then
newWidth = PictureBox1.Width * 1.25
newHeight = PictureBox1.Height * 1.25
Else
newWidth = PictureBox1.Width / 1.25
newHeight = PictureBox1.Height / 1.25
End If

If newWidth > pnPic.ClientSize.Width Or newHeight > pnPic.ClientSize.Height Then
PictureBox1.Dock = DockStyle.None
PictureBox1.Location = New Point(0, 0)
PictureBox1.Width = newWidth
PictureBox1.Height = newHeight
Else
PictureBox1.Dock = DockStyle.Fill
End If

PictureBox1.Refresh()
End Sub

Region

End Class

NUMBER PUZZLE-------------------------------------SOURCE-------------FORM1--------------Public Class Form1    Dim a = 1 ...
26/03/2015

NUMBER PUZZLE
-------------------------------------
SOURCE
-------------
FORM1
--------------
Public Class Form1
Dim a = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label2.Text = Format(TimeOfDay)
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Label4.Text = a
a = a + 1
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
Label2.Text = "0"
Label4.Hide()
Button1.Hide()
Button2.Hide()
Button3.Hide()
Button4.Hide()
Button5.Hide()
Button6.Hide()
Button7.Hide()
Button8.Hide()
Button9.Hide()
ContinueToolStripMenuItem.Enabled = False
End Sub

Private Sub StartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartToolStripMenuItem.Click
Label4.Visible = True
Timer2.Start()
Button1.Visible = True
Button2.Visible = True
Button3.Visible = True
Button4.Visible = True
Button5.Visible = True
Button6.Visible = True
Button7.Visible = True
Button8.Visible = True
Button9.Visible = True
End Sub

Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
Timer2.Stop()
End Sub

Private Sub StopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopToolStripMenuItem.Click
Timer2.Stop()
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End
End Sub

Private Sub RegistrationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegistrationToolStripMenuItem.Click
Form2.Show()
End Sub

Private Sub shuffle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles shuffle.Click
randomize()
a = 0
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
chk_result()
check(Button1, Button2)
check(Button1, Button4)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
chk_result()
check(Button2, Button1)
check(Button2, Button3)
check(Button2, Button5)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
chk_result()
check(Button3, Button2)
check(Button3, Button6)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
chk_result()
check(Button4, Button1)
check(Button4, Button5)
check(Button4, Button7)
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
chk_result()
check(Button5, Button2)
check(Button5, Button4)
check(Button5, Button6)
check(Button5, Button8)
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
chk_result()
check(Button6, Button3)
check(Button6, Button5)
check(Button6, Button9)
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
chk_result()
check(Button7, Button4)
check(Button7, Button8)
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
chk_result()
check(Button8, Button5)
check(Button8, Button7)
check(Button8, Button9)
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
chk_result()
check(Button9, Button6)
check(Button9, Button8)
End Sub

Private Sub PauseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PauseToolStripMenuItem.Click
Timer2.Stop()
ContinueToolStripMenuItem.Enabled = True
End Sub

Private Sub ContinueToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContinueToolStripMenuItem.Click
Timer2.Start()
ContinueToolStripMenuItem.Enabled = False
End Sub
End Class
------------------
MODULE 1:
----------------
Public Module Module1
Sub randomize()
Form1.Button1.Text = 2
Form1.Button2.Text = 1
Form1.Button3.Text = 6
Form1.Button4.Text = 5
Form1.Button5.Text = 7
Form1.Button6.Text = 8

Form1.Button7.Text = 3
Form1.Button8.Text = 4
Form1.Button9.Text = ""
End Sub
End Module
-------------------
MODULE 2:
---------------
Module Module2
Sub check(ByVal btn1 As Button, ByVal btn2 As Button)
If (btn2.Text = "") Then
btn2.Text = btn1.Text
btn1.Text = ""
End If
End Sub
End Module
---------------
MODULE 3:
---------------
Module Module3
Sub chk_result()
If (
Form1.Button1.Text = "1" And
Form1.Button2.Text = "2" And
Form1.Button3.Text = "3" And
Form1.Button4.Text = "4" And
Form1.Button5.Text = "5" And
Form1.Button6.Text = "6" And
Form1.Button7.Text = "7" And
Form1.Button8.Text = "8" And
Form1.Button9.Text = "") Then
Form1.Timer2.Stop()
MsgBox("CONGRATS you WON the game.. in" & Form1.Label4.Text & "seconds", MsgBoxStyle.Information)
End If

End Sub
End Module

Snake Game---------------------------------Source Code:------------------Option Explicit On Imports System.Drawing.Graph...
10/02/2015

Snake Game
---------------------------------
Source Code:
------------------
Option Explicit On
Imports System.Drawing.Graphics
Public Class Form1
Inherits System.Windows.Forms.Form

" Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Public WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Timer2 As System.Windows.Forms.Timer
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Timer2 = New System.Windows.Forms.Timer(Me.components)
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Timer1
'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 25
'
'Label1
'
Me.Label1.BackColor = System.Drawing.Color.Transparent
Me.Label1.Location = New System.Drawing.Point(16, 424)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(48, 16)
Me.Label1.TabIndex = 0
'
'Label2
'
Me.Label2.BackColor = System.Drawing.Color.Transparent
Me.Label2.Location = New System.Drawing.Point(80, 424)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(48, 16)
Me.Label2.TabIndex = 1
'
'Label3
'
Me.Label3.BackColor = System.Drawing.Color.Transparent
Me.Label3.Location = New System.Drawing.Point(144, 424)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(48, 16)
Me.Label3.TabIndex = 2
'
'Timer2
'
Me.Timer2.Interval = 25
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(200, 424)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(48, 16)
Me.Label4.TabIndex = 3
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(264, 424)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(48, 16)
Me.Label5.TabIndex = 4
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(320, 424)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(48, 16)
Me.Label6.TabIndex = 5
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
Me.BackColor = System.Drawing.Color.White
Me.ClientSize = New System.Drawing.Size(738, 452)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Name = "Form1"
Me.Text = "Snake"
Me.ResumeLayout(False)

End Sub

Region
Public snake As Pen = New Pen(Color.Tomato, 2)
Public snake_erase As Pen = New Pen(Color.White, 2)
Public food As Pen = New Pen(Color.Black, 1)
Public food_erase As Pen = New Pen(Color.White, 1)
Public x1 = 0, y1 = 20, x2 = 1, y2 = 20, counter = 1, value = 0, points = 0, prev = "", keypressed, foodx, foody, i
Public X(500000) As Int64
Public Y(500000) As Int64

Public Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If (counter = 80) Then Timer2.Enabled = True
If (counter = 80) Then Show_Food()

If (keypressed = "down") Then
prev = "up"
Range()
Valid()
For i = 0 To counter - 1
If (x2 = X(value) And y2 = Y(value)) Then MessageBox.Show("GameOver")
i = i + 1
Next
X(counter) = x2 : Y(counter) = y2 : counter = counter + 1
y2 = y2 + 1
ElseIf (keypressed = "left") Then
prev = "right"
Range()
Valid()
For i = 0 To counter - 1
If (x2 = X(value) And y2 = Y(value)) Then MessageBox.Show("GameOver")
i = i + 1
Next
X(counter) = x2 : Y(counter) = y2 : counter = counter + 1
x2 = x2 - 1
ElseIf (keypressed = "right") Then
prev = "left"
Range()
Valid()
For i = 0 To counter - 1
If (x2 = X(value) And y2 = Y(value)) Then MessageBox.Show("GameOver")
i = i + 1
Next
X(counter) = x2 : Y(counter) = y2 : counter = counter + 1
x2 = x2 + 1
ElseIf (keypressed = "up") Then
prev = "down"
Range()
Valid()
For i = 0 To counter - 1
If (x2 = X(value) And y2 = Y(value)) Then MessageBox.Show("GameOver")
i = i + 1
Next
X(counter) = x2 : Y(counter) = y2 : counter = counter + 1
y2 = y2 - 1
Else

End If
Label5.Text = keypressed : Label6.Text = value
Label3.Text = counter - 1 : Label1.Text = X(counter - 1) : Label2.Text = Y(counter - 1)
End Sub

Public Sub Valid()
Me.CreateGraphics.DrawLine(snake, x1, y1, x2, y2)
If ((x2 > Me.Width - 5) Or y2 > (Me.Height - 20) Or (x2 < 0) Or (y2 < 0)) Then Timer1.Stop() : MessageBox.Show("Game Over", "Game Over") : Me.Dispose(True)
x1 = x2 : y1 = y2
End Sub

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If (e.KeyCode = Keys.Down) And ((prev = "up") Or (prev = "right") Or (prev = "left") Or (prev = "")) Then keypressed = "down"
If (e.KeyCode = Keys.Up) And ((prev = "down") Or (prev = "") Or (prev = "right") Or (prev = "left")) Then keypressed = "up"
If (e.KeyCode = Keys.Right) And ((prev = "left") Or (prev = "") Or (prev = "up") Or (prev = "down")) Then keypressed = "right"
If (e.KeyCode = Keys.Left) And ((prev = "right") Or (prev = "") Or (prev = "up") Or (prev = "down")) Then keypressed = "left"
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
X(0) = 0 : Y(0) = 20
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Me.CreateGraphics.DrawLine(snake_erase, X(value), Y(value), X(value + 1), Y(value + 1))
value = value + 1
End Sub

Public Sub Show_Food()
Dim RandomClass As New Random
foodx = RandomClass.Next(50, Me.Width - 80)
foody = RandomClass.Next(50, Me.Height - 80)
Me.CreateGraphics.DrawRectangle(food, foodx, foody, 1, 1)
End Sub

Public Sub Erase_Food()
Me.CreateGraphics.DrawRectangle(food_erase, foodx, foody, 1, 1)
End Sub

Public Sub Range()

If ((x2 = foodx) And (y2 = foody)) Then Erase_Food() : points = points + 1 : value = value - 16 : Show_Food()
'If ((x2 = foodx - 1) And (y2 = foody)) Then Erase_Food() : points = points + 1 : value = value -5 : Show_Food()
'If ((x2 = foodx) And (y2 = foody - 1)) Then Erase_Food() : points = points + 1 : value = value - 5 : Show_Food()
'If ((x2 = foodx - 1) And (y2 = foody - 1)) Then Erase_Food() : points = points + 1 : value = value - 5 : Show_Food()
If ((x2 = foodx + 1) And (y2 = foody + 1)) Then Erase_Food() : points = points + 1 : value = value - 16 : Show_Food()
If ((x2 = foodx + 1) And (y2 = foody)) Then Erase_Food() : points = points + 1 : value = value - 16 : Show_Food()
If ((x2 = foodx) And (y2 = foody + 1)) Then Erase_Food() : points = points + 1 : value = value - 16 : Show_Food()

'If ((x2 = foodx - 2) And (y2 = foody)) Then Erase_Food() : points = points + 1 : value = value - 5 : Show_Food()
'If ((x2 = foodx) And (y2 = foody - 2)) Then Erase_Food() : points = points + 1 : value = value - 5 : Show_Food()
'If ((x2 = foodx - 2) And (y2 = foody - 2)) Then Erase_Food() : points = points + 1 : value = value - 5 : Show_Food()
If ((x2 = foodx + 2) And (y2 = foody + 2)) Then Erase_Food() : points = points + 1 : value = value - 16 : Show_Food()
If ((x2 = foodx + 2) And (y2 = foody)) Then Erase_Food() : points = points + 1 : value = value - 16 : Show_Food()
If ((x2 = foodx) And (y2 = foody + 2)) Then Erase_Food() : points = points + 1 : value = value - 16 : Show_Food()

Label4.Text = points
End Sub
End Class

Address

Chennai
625003

Website

Alerts

Be the first to know and let us send you an email when Dot net Projects posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share