Contact ~ Site Map ~ Navigation:   

 

Navigation
About Tutorials
Remove Background
Map Network Drive
Variable Naming
VB.NET Syntax
VB.NET to C#
Add Image

Learning The New VB.NET Syntax

If you're like me, you'll be trying to understand some of the changes to VB now that it has evolved into VB.NET. Below is a list of what the code was in VB6, followed by the new way of doing it in VB.NET.

VB6 VB.NET
DoEvents
VB6 Becomes VB.NET System.Windows.Forms.Application.DoEvents()
Command1.BackColor = vbRed
VB6 Becomes VB.NET Command1.BackColor = System.Drawing.Color.Red
ComboBox1.AddItem "one"
VB6 Becomes VB.NET ComboBox1.Items.Add("one")
Command1.BackColor = &H80C0FF
VB6 Becomes VB.NET Command1.BackColor = System.Drawing.ColorTranslator.FromOle(&H80C0FF&)
Form1.Caption = "Sample"
VB6 Becomes VB.NET Form1.Text = "Sample"
MsgBox "message", vbInformation, "title"
VB6 Becomes VB.NET MessageBox.Show("message", "title", , MessageBoxIcon.Information)
Set MyObject = Command1
VB6 Becomes VB.NET MyObject = Command1
Text1.SetFocus
VB6 Becomes VB.NET Text1.Focus()
Command1.ToolTipText = "click me"
VB6 Becomes VB.NET ToolTip1.SetToolTip(Command1, "click me")
Dim objAbout As AboutForm
VB6 Becomes VB.NET Dim objAbout As Pharfruminsain_AboutForm_v1r0.AboutForm
sPath = App.Path
VB6 Becomes VB.NET sPath = System.Environment.CurrentDirectory
Private Sub Form_Unload(Cancel As Integer)
VB6 Becomes VB.NET Private Sub Form1_Closing(...) Handles MyBase.Closing
List1.RemoveItem (0)
VB6 Becomes VB.NET ListBox1.Items.Remove(0)
Dim arOne(10) As String
VB6 Becomes VB.NET Dim arOne As New ArrayList(10)
Open "c:\myfile.txt" For Input As #1
VB6 Becomes VB.NET FileOpen(1, "c:\myfile.txt", OpenMode.Input)
Line Input #1, sTemp
VB6 Becomes VB.NET sTemp = LineInput(1)
Print #1, "sample text"
VB6 Becomes VB.NET PrintLine(1, "sample text")
Public Type CustomArray
VB6 Becomes VB.NET Public Structure CustomArray
Dim xRed As OLE_COLOR
VB6 Becomes VB.NET Dim xRed As System.Drawing.Color
List1.ListIndex = List1.ListCount - 1
VB6 Becomes VB.NET List1.SelectedIndex = List1.Items.Count - 1
Me.MousePointer = vbHourglass
VB6 Becomes VB.NET Cursor.Current = Cursors.WaitCursor
Private Sub Label1_Change()
VB6 Becomes VB.NET Private Sub Label1_TextChanged(....) Handles Label1.TextChanged
Form2.Show
VB6 Becomes VB.NET Dim xForm As New Form2()   {next line}   xForm.Show()
sModelOfCar = Trim(sModelOfCar)
VB6 Becomes VB.NET sModelOfCar = sModelOfCar.Trim()
iCount = iCount + 1
VB6 Becomes VB.NET iCount += 1
sText = sText & "hello"
VB6 Becomes VB.NET sText += "hello"
TextBox1.Text = ""
VB6 Becomes VB.NET TextBox1.Clear()
Unload Me
VB6 Becomes VB.NET Me.Dispose

 
© Copyright 1999 - 2017 Pharfruminsain.com, All Rights Reserved.