| VB6.0和VB.Net的對照表 |
| VB6.0 | VB.NET |
| AddItem Object名.AddItem | Object名.Items.AddListBox1.Items.AddComboBox1.Items.Add |
| Abs 函數 | System.Math.Abs 方法 |
| API 函數關係 | Microsoft Win32和Microsoft .NET Framework API的對應 |
| App.Path等 | 1. System.Reflection.Assembly.GetExecutingAssembly.Location
2. Application.StartupPath
3. Application.ExecutablePath
4. System.AppDomain.CurrentDomain.BaseDirectory |
| App.PrevInstance | Process.GetProcessesByName(pn).GetUpperBound(0) > 0 |
| As Any 關鍵詞 | Visual Basic .NET 不提供支援。 參考方法(SendMessage) |
| AscB 函數 | Microsoft.VisualBasic.Strings.Asc 函數 |
| Atn 函數 | System.Math.Atan 方法 |
| AutoRedraw 屬性 | 沒有相同項目。 |
| Beep | Microsoft.VisualBasic.Beep() |
| Caption 屬性 | Text 屬性 |
| CBool 函數 | CBool 函數 |
| CByte 函數 | CByte 函數 |
| CDate 函數 | CDate 函數 |
| CDbl 函數 | CDbl 函數 |
| CDec 函數 | CDec 函數 |
| ChDir 語句 | Microsoft.VisualBasic.FileSystem.ChDir 函數
System.IO.Directory.SetCurrentDirectory 方法 |
| ChDrive 語句 | Microsoft.VisualBasic.FileSystem.ChDrive 函數 |
| Chr$ 函數、ChrB 函數 | Microsoft.VisualBasic.Strings.Chr 函數 |
| CInt 函數 | CInt 函數 |
| Circle 方法 | System.Drawing.Graphics.DrawEllipse 方法 |
| CLong 函數 | CLong 函數 |
| Close 語句 | Microsoft.VisualBasic.FileSystem.FileClose 函數
System.IO.StreamReader.Close 方法 |
| Clipboard 對象 | System.Windows.Forms.Clipboard 命名空間 |
| ClipControls 屬性 | 沒有相同項目。 |
| Cls 方法 | System.Drawing.Graphics.Clear 方法 |
Color QBColor
vbBlack RGB() | System.Drawing.Color.Black |
| Command | System.Environment.GetCommandLineArgs |
| Combo1.AddItem | ComboBox1.Items.Add |
| Cos 函數 | System.Math.Cos 方法 |
| CSng 函數 | CSng 函數 |
| CStr 函數 | CStr 函數 |
| CurDir 函數 | System.IO.Directory.GetCurrentDirectory() 方法 |
| Currency 類型 | Decimal 類型 |
| CurrentX 屬性 | 各種圖形相關方法的 x 參數。比如、DrawRectangle(pen, x, y, width, height) |
| CurrentY 屬性 | 各種圖形相關方法的 y 參數。比如、DrawRectangle(pen, x, y, width, height) |
| Date 函數、Date 語句 | System.DateTime.Now System.DateTime.Today.ToString |
| Date$ 函數 | Microsoft.VisualBasic.DateAndTime.DateString |
| DateAdd 函數 | System.DateTime.AddYears 方法 AddMonths AddDays |
| DateDiff 函數 | Microsoft.VisualBasic.DateDiff 函數 |
| DateValue 函數 | System.DateTime.Parse 方法 CDate 函數 |
| DatePart 函數 | Microsoft.VisualBasic.DatePart 函數 |
| Day 函數 | System.DateTime.Day 屬性 |
| Debug.Print | Debug.WriteLine |
| DeleteSetting 語句 | Microsoft.VisualBasic.Interaction.DeleteSetting |
| DoEvents 函數 | System.Windows.Forms.Application.DoEvents 方法 |
| DrawMode 屬性 | System.Drawing.Pen.Color 屬性 |
| DrawStyle 屬性 | System.Drawing.Pen.PenType 屬性 |
| DrawWidth 屬性 | System.Drawing.Pen.Width 屬性 |
| Environ | Microsoft.VisualBasic.Interaction.Environ
System.Environment.GetFolderPath |
| Exp 函數 | System.Math.Exp 方法 |
| FillColor 屬性 | System.Drawing.SolidBrush.Color 屬性 |
| FileCopy 語句 | Microsoft.VisualBasic.FileSystem.FileCopy 函數
System.IO.File.Copy 方法 |
| FileLen 函數 | System.IO.FileInfo.Length 屬性
Microsoft.VisualBasic.FileSystem.FileLen |
| FillStyle 屬性 | System.Drawing.Pen.Brush 屬性 |
| Get 語句 | Microsoft.VisualBasic.FileSystem.FileGet 函數 |
| GetAttr | System.IO.File.GetAttributes |
| GotFocus 事件 | Enter 事件 |
| GetSetting 語句 | Microsoft.VisualBasic.Interaction.GetSetting |
| FileDateTime 函數 | System.IO.File.GetCreationTime 方法 |
| HasDC 屬性 | 沒有相同項目。 |
| HDC 屬性 | 沒有相同項目。 |
| Height 屬性 | Control.Size 屬性 |
| Hour 函數 | System.DateTime.Hour 屬性 |
| hwnd Form1.hwnd | Form1.Handle 定義處也是 ByVal hWnd As IntPtr |
| Image 屬性 | Image 屬性 |
| Input # 語句 | Microsoft.VisualBasic.FileSystem.Input 函數 |
| InStr 函數 | System.String.IndexOf
Microsoft.VisualBasic.Strings.InStr 函數 |
| InStrB 函數 | Microsoft.VisualBasic.Strings.InStr 函數 |
| InStrRev 函數 | System.String.LastIndexOf 方法
Microsoft.VisualBasic.Strings.InStrRev 函數 |
| Int 函數 | System.Math.Floor 方法 System.Math.Ceiling 方法
Microsoft.VisualBasic.Int 函數 |
| Integer 類型 Long 類型 | Dim y As Integer 改為 Dim x As Short
Dim y As Long 改為 Dim y As Integer |
| IsEmpty 函數 | Microsoft.VisualBasic.Information.IsNothing 函數 |
| IsDate 函數 | Microsoft.VisualBasic.IsDate 函數 |
| IsNull 函數 | Microsoft.VisualBasic.Information.IsDBNull 函數 |
| IsObject 函數 | Microsoft.VisualBasic.Information.IsReference 函數 |
| Join 函數 | System.String.Join 方法 |
| KeyAscii | e.KeyChar 屬性 |
| Kill 語句 | Microsoft.VisualBasic.FileSystem.Kill 函數
System.IO 命名空間 FileInfo.Delete 方法 |
| LBound UBound | System.Array.GetLowerBound System.Array.GetUpperBound |
| LCase$ 函數 | String.ToLower 方法
Microsoft.VisualBasic.Strings.LCase 函數 |
| Left 屬性 | Control.Location 屬性 |
| Left$、LeftB、LeftB$ | System.String.SubString
Microsoft.VisualBasic.Strings.Left 函數 |
| Len | System.String.Length
Microsoft.VisualBasic.Strings.Len |
| LenB | System.Text.Encoding.GetEncoding("gb2312").GetByteCount(str1)
System.Text.Encoding.Unicode.GetByteCount("123大小大") '結果 12
System.Text.Encoding.Default.GetByteCount("123大小大") '結果 9 |
| Line 方法 | System.Drawing.Graphics.DrawLine 方法 |
| Line Input # 語句 | Microsoft.VisualBasic.FileSystem.LineInput 函數 |
| List1.AddItem | ListBox1.Items.Add |
| LoadPicture 函數 | System.Drawing.Image.FromFile("..\..\test.bmp") |
| Lock 語句 | Microsoft.VisualBasic.FileSystem.Lock 函數 |
| Log 函數 | system.Math.Log 方法 |
| Long 類型 Integer 類型 | Dim y As Integer 改為 Dim x As Short
Dim y As Long 改為 Dim y As Integer |
| LostFocus 事件 | Leave 事件 |
| LTrim$ 函數 | System.String.TrimStart
Microsoft.VisualBasic.Strings.LTrim 函數 |
| Mid 函數 | System.String.SubString
Microsoft.VisualBasic.Strings.Mid 函數 |
| MidB 函數 | Microsoft.VisualBasic.Strings.Mid 函數 |
| Minute 函數 | System.DateTime.Minute 屬性 |
| MkDir 語句 | Microsoft.VisualBasic.FileSystem.MkDir 函數
System.IO.Directory.CreateDirectory 方法 |
MousePointer=11
Screen.MousePointer | System.Windows.Forms.Cursors.WaitCursor()
System.Windows.Forms.Cursor.Current = Cursors.WaitCursor |
| Mod 運算符 | Math.IEEERemainder 方法Debug.WriteLine(Math.IEEERemainder(10, 3)) '結果 1
System.Math.DivRem(10, 3, intResult) '結果 3 (10 \ 3)
Debug.WriteLine(intResult) '結果 1 (10 Mod 3) |
| Month 函數 | System.DateTime.Month 屬性 |
| MsgBox | System.Windows.Forms.MessageBox.Show("Hello, world!")
Microsoft.VisualBasic.MsgBox |
| Name 語句 | Microsoft.VisualBasic.FileSystem.Rename 函數 |
| Now 函數 | System.DateTime.Now Microsoft.VisualBasic.Now |
| Open 語句 | Microsoft.VisualBasic.FileSystem.FileOpen 函數 |
| Option Base 語句 | Visual Basic .NET沒有提供支援。 |
| Option Private | Visual Basic .NET沒有提供支援。 |
| PaintPicture 方法 | System.Drawing.Graphics.DrawImage 方法 |
| Point 方法 | 不存在相同的Form和控件。
使用Bitmap時用System.Drawing.Bitmap.GetPixel 方法 |
| Print 方法 | System.Drawing.Graphics.DrawString 方法 |
| PrintForm | Visual Basic .NET沒有提供支援。 |
| Print# 語句 | Microsoft.VisualBasic.FileSystem.Print 函數 |
Private 語句
Public 語句 | Private Public
Friend Protected Protected Friend |
| Pset 方法 | 不存在相同的Form和控件。
使用Bitmap時用System.Drawing.Bitmap.SetPixel 方法 |
| Put 語句 | Microsoft.VisualBasic.FileSystem.FilePut 函數 |
| Replace 函數 | Microsoft.VisualBasic.Strings.Replace 函數 |
| Right$ 函數、RightB 函數 | System.String.SubString
Microsoft.VisualBasic.Strings.Right 函數 |
| ReDim 語句 | ReDim MyArray(5) ReDim Preserve MyArray(15) 語句 |
| RmDir 語句 | Microsoft.VisualBasic.FileSystem.RmDir 函數 System.IO.Directory.Delete() 方法 |
| Round 函數 | System.Math.Round 方法 |
| RTrim$ 函數 | System.String.TrimEnd
Microsoft.VisualBasic.Strings.RTrim |
| SaveSetting 語句 | Microsoft.VisualBasic.Interaction.SaveSetting 函數 |
| Scale 方法 | Visual Basic .NET沒有提供支援。 |
Screen.ActiveControl
<>ActiveForm
Screen.Fonts
Screen.Height
Screen.MousePointer
Screen.Width
其他 Screen 對象 | System.Windows.Forms.Application.ActiveForm.ActiveControl
System.Windows.Forms.Application.ActiveForm
System.Drawing.FontFamilies
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
System.Drawing.Cursor.Current
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
其他 |
| Second 函數 | System.DateTime.Second 屬性 |
| SendKeys 語句 | System.Windows.Forms.SendKeys.Send("^C") |
| SetAttr | System.IO.File.SetAttributes |
| Sgn 函數 | System.Math.Sign 函數 |
| Shell | Microsoft.VisualBasic.Shell |
| Sin 函數 | System.Math.Sin 函數 |
| Space 函數 | Microsoft.VisualBasic.Strings.Space 函數 |
| Sqr 函數 | System.Math.Sqrt 函數 |
| StrComp 函數 | Microsoft.VisualBasic.Strings.StrComp 函數 |
| StrConv 函數 | Microsoft.VisualBasic.Strings.StrConv 函數 |
| String$(256, Chr(0)) | buf = New String(CChar(" "), 256)Microsoft.VisualBasic.Strings.StrDup 函數 |
| StrReverse 函數 | Microsoft.VisualBasic.Strings.StrReverse 函數 |
| Tan 函數 | System.Math.Tan 方法 |
| TextHeight 屬性 | System.Drawing.Font.Height 屬性 |
| TextWidth 屬性 | System.Drawing.Graphics.MeasureString 方法 |
| Time$ 函數 | Microsoft.VisualBasic.DateAndTime.Timer 屬性
System.DateTime.Now.TimeOfDay |
| TimeValue 函數 | System.DateTime.Parse 方法 CDate 函數 |
| Top 屬性 | Control.Location 屬性 |
| Trim$ 函數 | Microsoft.VisualBasic.Strings.Trim 函數
System.String.Trim |
| Type 語句 | Structure 語句 |
| UCase$ 函數 | String.ToUpper 方法
Microsoft.VisualBasic.Strings.UCase 函數 |
| Unlock 語句 | Microsoft.VisualBasic.FileSystem.Unlock 函數 |
| Unload 事件 | Closed 事件 Me.Close() |
| Variant 型 | Dim x As Variant 改為 Dim x As Object |
| VarPtr、StrPtr、ObjPtr | Dim MyGCHandle As GCHandle = GCHandle.Alloc(o,GCHandleType.Pinned)
Dim Address As Integer = CInt(MyGCHandle.AddrOfPinnedObject()) |