Round(2.5, 0) daje wynik 2, a Round(3.5, 0) zwróci 4. Podczas operacji dzielenia operatorem „/”, liczby całkowite automatycznie są konwertowane do typu rzeczywistego, przez co wynik jest bardziej intuicyjny. Jeżeli zmienna nie została zadeklarowana, lub podczas deklaracji nie został podany typ zmiennej, automatycznie otrzymuje ona typ „Variant”. Może to być zmienione za pomocą instrukcji DefType takich jak „DefInt”, „DefBool”, „DefVar”, „DefObj”, „DefStr”. Takich instrukcji jest w sumie 12 w specyfikacji Visual Basic 6.0.

Przykłady Program wyświetlający wiadomość okienkową. Private Sub Form_Load() MsgBox ("Hello World !") End Sub

Zapis do pliku w języku VB. My.Computer.FileSystem.WriteAllText("C:\Test\test.txt","This is new text to be added.",True)

Pętla foreach Dim numbers() As Integer = {1, 2, 3} For Each number As Integer In numbers Debug.Write(number.ToString) Next Debug.WriteLine("")

Instrukcja switch Dim number As Integer = 5 Select Case number Case 1 To 5 Debug.WriteLine("Between 1 and 5, inclusive") Case 6, 7, 8 Debug.WriteLine("Between 6 and 8, inclusive") Case 9 To 10 Debug.WriteLine("Equal to 9 or 10") Case Else Debug.WriteLine("Not between 1 and 10, inclusive") End Select

Zobacz też Visual Basic .NET

Przypisy

Linki zewnętrzne Oficjalna strona Visual Basic Visual Basic 6.0 Resource Center

Kategoria:BASIC Kategoria:Zintegrowane środowisko programistyczne