[VB.net] Useful things to add into vb.net program
Posted: 26 Dec 2010, 06:29
Here are some useful codes to add into your vb.net program
1. message box:
2. message box with yes/no options:
other options to use instead of vbyes and vbno:
3. start a process 2 examples:
4. kill a process:
change taskmgr.exe to anything u want
5. delete a registry key:
6. create a registry key:
change MyApp to whatever your program is called
7. start a timer:
8. stop a timer:
9.close program:
10.hide your program:
1. message box:
Code: Select all
MsgBox("TextHere")
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
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")
Code: Select all
Dim RunningProcess As System.Diagnostics.Process = Process.GetProcessesByName("taskmgr.exe")(0)
RunningProcess.Kill()
5. delete a registry key:
Code: Select all
My.Computer.Registry.LocalMachine.DeleteSubKey("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SafeBoot")
Code: Select all
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
regKey.CreateSubKey("MyApp")
regKey.Close()
7. start a timer:
Code: Select all
Timer.Start ()
Code: Select all
Timer.Stop ()
Code: Select all
Me.Close ()
Code: Select all
Me.Hide ()