[VB.net] Useful things to add into vb.net program

A Place For Programmers Of All Levels To Discuss Programming & Web Building.

Moderator: Community Moderator

Post Reply
User avatar
djfshady
Corporal
Corporal
Posts: 25
Joined: 26 Nov 2010, 20:12
Location: United Kingdom
Been thanked: 5 times
Contact:

[VB.net] Useful things to add into vb.net program

Post by djfshady »

Here are some useful codes to add into your vb.net program


1. message box:

Code: Select all

MsgBox("TextHere")
2. message box with yes/no options:

Code: Select all

Dim Responce As Integer
Responce = MsgBox("Are You Sure", vbYesNo, "DELETE")
If Responce = vbYes Then
  MsgBox(" You Clicked Yes!")
Else
MsgBox("You Clicked No!")
End If
other options to use instead of vbyes and vbno:

Code: Select all

vbYesNoCancel
vbCritical
vbExcalmation
vbInformation
vbMsgBoxHelp
vbMsgBoxRight
vbOkOnly
vbRetryCancel
vbDefaultButton1
vbDefaultButton2
vbDefaultButton3
vbApplicationmodal
vbQuestion
vbOkCancel
vbAbortRetryIgnore

3. start a process 2 examples:

Code: Select all

Process.Start("mspaint")
Process.Start("www.hackerscorner.co.uk")
4. kill a process:

Code: Select all

Dim RunningProcess As System.Diagnostics.Process = Process.GetProcessesByName("taskmgr.exe")(0)
RunningProcess.Kill()
change taskmgr.exe to anything u want

5. delete a registry key:

Code: Select all

My.Computer.Registry.LocalMachine.DeleteSubKey("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SafeBoot")
6. create a registry key:

Code: Select all

Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
regKey.CreateSubKey("MyApp")
regKey.Close()
change MyApp to whatever your program is called
7. start a timer:

Code: Select all

Timer.Start ()
8. stop a timer:

Code: Select all

Timer.Stop ()
9.close program:

Code: Select all

Me.Close ()
10.hide your program:

Code: Select all

Me.Hide ()
Image
Post Reply

Return to “Programming/Web Building Chat & Support”