VBTheory™ Tutorials

VBTheory Tutorials, A New World Of Programming

Free C# and VB.NET tutorials for everyone.

More involving than others

VBTheory Tutorials uses many social networks in order to involve its audience.

Tuesday, June 19, 2012

Exit Prompt (2 Different Ways) - VB#19


Code:
Method One (Would you like to exit with two buttons):
Dim result as msgboxresult = msgbox("Are you sure you would like to exit?", vbyesno)
Select Case result
   Case vbYes
      end
   Case vbNo
      e.cancel=true
End Select

Method Two (Would you like to save with three buttons):
Dim result as msgboxresult = msgbox("Are you sure you would like to save before exiting?", vbyesnocancel)
Select Case result
   Case vbYes
      'Your saving code here
      end
   Case vbNo
      end
   Case vbCancel
      e.cancel=true
End Select



Monday, June 11, 2012

Monday, June 4, 2012

How To Read Subfolders - VB#17


Code:


OpenFileDialog1.ShowDialog()
For Each folder in My.Computer.FileSystem.GetDirectories(YOURFOLDERPATHHERE)
     For Each dir in My.Computer.FileSystem.GetFiles(folder)
          ListBox1.Items.Add(dir)
     Next
Next



Monday, May 28, 2012

Passing Settings Between Programs - VB#16


Code:
Receiver app:
Label1.Text=Command()
Label1.Refresh()

Sender app:
System.Diagnostics.Process.Start(FILE NAME HERE, Textbox1.Text)



Monday, May 21, 2012

Most Advanced Login System On Youtube - VB #15


Download link:
Click Here



Monday, May 14, 2012

Read A Random Line (EASY WAY) - VB#14


Code:
 
Dim sr As New System.IO.StreamReader(FILEPATH)
Dim sr2 As New System.IO.StreamReader(FILEPATH)
Dim i As Integer = 0
Dim curline As Integer = 0
Dim ran As Integer = 0
Do Until sr.EndOfStream = True
  sr.ReadLine()
  i += 1
Loop
sr.Dispose()
sr.Close()
Randomize()
ran = Rnd() * i
Do Until ran = curline
  TextBox1.Text = sr2.ReadLine()
  curline += 1
Loop



Wednesday, May 9, 2012

Working With Tooltips - VB#13


Code:

tooltip1.SetTooltip(CONTROLNAME, TEXT HERE IN QUOTES)



Monday, April 30, 2012

Try Statement And Error Handling - VB#12


Code:


Try
   'Your code here
Catch ex as exception
    'Your error handling code here
End Try



Monday, April 23, 2012

Registry - VB #11


There are a lot of codes for registry, it's better to experiment with all of them



Monday, April 16, 2012

How To Get All The Installed Fonts - VB#10


Code:

Imports System.Drawing.Text

In your button click event:
Dim installed_fonts As New InstalledFontCollection
Dim font_families() As FontFamily = installed_fonts.Families()
For Each font_family As FontFamily In font_families
  Listbox1.Items.Add(font_family.name)
Next font_family

In your listbox indexchanged event:
TextBox1.Font=New Font(Listbox1.Text, 8.25)



Share