Programmation Visual Basic .NET/Fonctions VB6 en .NET

Un livre de Wikilivres.
Sauter à la navigation Sauter à la recherche
Visual Basic .NET
Visual Basic .NET
Sommaire

Bases du langage
Opérateurs
Programmation orientée objet
Structure de données avancée
Modifier ce modèle

Cette table de conversion compare Visual Basic 6 à Visual Basic .NET (sachant que ce dernier accepte aussi les fonctions VB6 via Microsoft.VisualBasic namespace).

Divers[modifier | modifier le wikicode]

Visual Basic 6 .NET Equivalent
App.Path Application.StartupPath
CallByName Type Object.InvokeMember
Circle Graphics Object.DrawEllipse
Collection Collections.Hashtable, Collections.Dictionary
Command Environment.GetCommandLineArgs
DoEvents Application.DoEvents
Environ Environment.GetEnvironmentVariable
Err Deprecated - Use Exception object and Try ... Catch ... End Try statement
Error Exception Object.Message
GetSetting Deprecated - Look into Configuration.ConfigurationSettings
IIf Deprecated
InputBox Deprecated - Make your own form
Len Runtime.InteropServices.Marshal.SizeOf
MsgBox MessageBox.Show
RGB Color Object.FromArgb
SavePicture Image Object.Save
SaveSetting Deprecated - Look into Configuration.ConfigurationSettings
SendKeys SendKeys.Send
Shell Process.Start
Switch Deprecated
TypeName Any Object.GetType.ToString
Unload Deprecated
VarType Any Object.GetType

Chaines de caractères[modifier | modifier le wikicode]

Visual Basic 6 .NET Equivalent
Asc Convert.ToInt32(Char)
Chr Convert.ToChar
Format Any Object.ToString(Format String)
FormatCurrency Any Numeric Object.ToString("c")
FormatDateTime Date Object.ToString(Format String), Date Object.ToLongDateString
FormatNumber Any Numeric Object.ToString(Format String)
FormatPercent Any Numeric Object.ToString("p")
Hex Integer Object.ToString("x"), Convert.ToString(Integer, 16)
InStr String Object.IndexOf
InStrRev String Object.LastIndexOf
Join String.Join
LCase String Object.ToLower
Left String Object.Substring
Len String Object.Length
LTrim String Object.TrimStart
Mid String Object.Substring
Oct Convert.ToString(Integer, 8)
Replace String Object.Replace
Right String Object.Substring
RTrim String Object.TrimEnd
Space String Object.PadLeft, String Object.PadRight
Split String Object.Split
String String Object = New String(Char, Count)
StrReverse Dim c() As Char = Array.Reverse(String Object.ToCharArray)
Trim String Object.Trim
UCase String Object.ToUpper

Fichiers et répertoires[modifier | modifier le wikicode]

Visual Basic 6 .NET Equivalent
ChDir IO.Directory.SetCurrentDirectory
CurDir IO.Directory.GetCurrentDirectory
Dir IO.Directory.GetFiles, IO.Directory.GetDirectories, IO.Directory.Exists, IO.File.Exists
EOF IO.StreamReader.Peek = -1
FileAttr Deprecated - Use StreamReader or StreamWriter
FileCopy IO.File.Copy
FileDateTime IO.File.GetLastAccessTime, IO.File.GetCreationTime
FileLen IO.FileStream Object.Length
GetAttr IO.File.GetAttributes
Loc IO.Stream Object.Position
LOF IO.Stream Object.Length
MkDir IO.Directory.CreateDirectory
RmDir IO.Directory.Delete
SetAttr IO.File.SetAttributes

Tableaux[modifier | modifier le wikicode]

Visual Basic 6 .NET Equivalent
Filter Array.BinarySearch
UBound Any Type of Array.GetUpperBound(0)

Dates[modifier | modifier le wikicode]

Visual Basic 6 .NET Equivalent
DateAdd Date Object.Add
DateDiff Date Object.Subtract
Now DateTime.Now

Math[modifier | modifier le wikicode]

Visual Basic 6 .NET Equivalent
Abs Math.Abs
Atn Math.Atan
Cos Math.Cos
Exp Math.Exp
Fix Math.Floor (for negative numbers), Math.Ceiling (for positive numbers)
Int Math.Floor
Log Math.Log
Randomize Deprecated - Random Object is automatically randomized declared
Rnd System.Random Object.Next
Round Math.Round
Sgn Math.Sign
Sin Math.Sin
Sqr Math.Sqrt
Tan Math.Tan

Références[modifier | modifier le wikicode]

Voir aussi[modifier | modifier le wikicode]