VB.NETを始めたばかりで、「どう書けばいいの?」「他の言語と何が違うの?」と戸惑っていませんか?
VB.NETは、Microsoftが開発したプログラミング言語で、読みやすい英語のような構文が特徴です。セミコロンや中括弧が不要なので、初心者にも優しい言語と言えます。
この記事では、VB.NETの基本構文を、プログラミング初心者の方にも分かるように丁寧に解説します。変数の宣言から条件分岐、ループ処理、関数の作り方まで、実務で必要な構文を網羅しています。
VB.NETとは

VB.NET(Visual Basic .NET) は、Microsoftが開発したプログラミング言語です。
主な特徴
読みやすい構文:
- 英語のような自然な書き方
- セミコロン(;)不要
- 中括弧({})不要
- 大文字小文字を区別しない
Windows開発に強い:
- WindowsアプリケーションがGUIで簡単に作れる
- Visual Studioとの統合が強力
- .NET Frameworkのすべての機能が使える
初心者に優しい:
- 構文エラーが少ない
- ドラッグ&ドロップで画面が作れる
- デバッグが簡単
プログラムの基本構造
まず、VB.NETのプログラムがどう書かれるか見てみましょう。
' モジュール宣言
Module Program
' メインメソッド(プログラムの開始点)
Sub Main()
' ここに処理を書く
Console.WriteLine("Hello, World!")
' プログラムを一時停止(コンソールアプリの場合)
Console.ReadLine()
End Sub
End Module
重要な点:
- プログラムは
ModuleまたはClassの中に書く Sub Main()がプログラムの開始点- 処理のブロックは
End Sub、End Ifなどで終了
コメントの書き方
コメントは、プログラムの説明を書くために使います。実行時には無視されます。
1行コメント
' これは1行コメントです
Dim x As Integer = 10 ' 行の途中からもコメントにできます
ポイント: '(シングルクォート)を使う
複数行コメント
Rem これも1行コメントです(古い書き方)
' 複数行をコメントにしたい場合は
' 各行の先頭に ' を付けます
' こうすることで複数行をコメントアウトできます
便利な機能: Visual Studioでは、選択した複数行に対して「Ctrl + K, Ctrl + C」でまとめてコメントアウトできます。
変数と定数
変数の宣言
変数は、データを一時的に保存する「箱」のようなものです。
基本構文:
Dim 変数名 As データ型
例:
' 整数型の変数
Dim age As Integer
' 文字列型の変数
Dim name As String
' 小数型の変数
Dim price As Double
' 真偽値型の変数
Dim isActive As Boolean
変数の宣言と同時に初期化
' 宣言と同時に値を代入
Dim age As Integer = 25
Dim name As String = "太郎"
Dim price As Double = 1980.5
Dim isActive As Boolean = True
' 型推論(データ型を省略)
Dim age = 25 ' 自動的にInteger
Dim name = "太郎" ' 自動的にString
Dim price = 1980.5 ' 自動的にDouble
複数の変数をまとめて宣言
' 同じ型の変数をまとめて宣言
Dim x, y, z As Integer
' 別々の型
Dim name As String, age As Integer, height As Double
注意: Dim x, y, z As Integer の場合、すべてInteger型になります。
定数の宣言
定数は、一度設定したら変更できない値です。
' 定数の宣言
Const TAX_RATE As Double = 0.1
Const MAX_COUNT As Integer = 100
Const APP_NAME As String = "MyApp"
' 使用例
Dim price As Double = 1000
Dim totalPrice As Double = price * (1 + TAX_RATE)
Console.WriteLine(totalPrice) ' 1100
命名規則: 定数は通常、すべて大文字で書き、単語をアンダースコアでつなぎます。
データ型
VB.NETで使える主なデータ型を紹介します。
数値型
| データ型 | 説明 | 範囲 | 例 |
|---|---|---|---|
| Byte | 符号なし8ビット整数 | 0 〜 255 | Dim b As Byte = 255 |
| Short | 16ビット整数 | -32,768 〜 32,767 | Dim s As Short = 1000 |
| Integer | 32ビット整数 | -2,147,483,648 〜 2,147,483,647 | Dim i As Integer = 100 |
| Long | 64ビット整数 | -9,223,372,036,854,775,808 〜 9,223,372,036,854,775,807 | Dim l As Long = 1000000 |
| Single | 単精度浮動小数点 | 約 ±1.4E-45 〜 ±3.4E+38 | Dim f As Single = 3.14 |
| Double | 倍精度浮動小数点 | 約 ±5.0E-324 〜 ±1.7E+308 | Dim d As Double = 3.14159 |
| Decimal | 高精度小数 | ±7.9E+28(有効桁数28〜29桁) | Dim m As Decimal = 19.95 |
使い分けのポイント:
- 整数:通常は
Integer - 小数:通常は
Double、お金の計算はDecimal
文字・文字列型
| データ型 | 説明 | 例 |
|---|---|---|
| Char | 1文字 | Dim c As Char = "A"c |
| String | 文字列 | Dim s As String = "こんにちは" |
' 文字列の例
Dim message As String = "Hello, World!"
Dim empty As String = "" ' 空文字列
Dim multiLine As String = "1行目" & vbCrLf & "2行目"
' 文字列の連結
Dim firstName As String = "太郎"
Dim lastName As String = "山田"
Dim fullName As String = lastName & firstName ' "山田太郎"
' 文字列補間(VB 14.0以降)
Dim name As String = "太郎"
Dim age As Integer = 25
Dim message As String = $"{name}さんは{age}歳です"
論理型
| データ型 | 説明 | 値 |
|---|---|---|
| Boolean | 真偽値 | True または False |
Dim isActive As Boolean = True
Dim isCompleted As Boolean = False
' 条件式の結果を格納
Dim isAdult As Boolean = (age >= 20)
日付型
| データ型 | 説明 | 例 |
|---|---|---|
| Date / DateTime | 日付と時刻 | Dim today As Date = #2025/12/8# |
' 日付の宣言
Dim today As Date = Date.Today
Dim now As DateTime = DateTime.Now
Dim specificDate As Date = #2025/12/8#
' 日付の操作
Dim tomorrow As Date = today.AddDays(1)
Dim nextMonth As Date = today.AddMonths(1)
' 日付の比較
If today > specificDate Then
Console.WriteLine("過去の日付です")
End If
オブジェクト型
' すべての型の基底クラス
Dim obj As Object = "何でも格納できる"
obj = 123
obj = True
注意: Object 型は何でも格納できますが、型安全性が失われるため、できるだけ具体的な型を使いましょう。
演算子
算術演算子
Dim a As Integer = 10
Dim b As Integer = 3
' 加算
Dim sum As Integer = a + b ' 13
' 減算
Dim diff As Integer = a - b ' 7
' 乗算
Dim prod As Integer = a * b ' 30
' 除算(実数)
Dim quotient As Double = a / b ' 3.333...
' 整数除算
Dim intDiv As Integer = a \ b ' 3
' 剰余(余り)
Dim remainder As Integer = a Mod b ' 1
' 累乗
Dim power As Double = a ^ 2 ' 100
比較演算子
Dim x As Integer = 10
Dim y As Integer = 20
' 等しい
Dim equal As Boolean = (x = y) ' False
' 等しくない
Dim notEqual As Boolean = (x <> y) ' True
' より小さい
Dim lessThan As Boolean = (x < y) ' True
' 以下
Dim lessOrEqual As Boolean = (x <= y) ' True
' より大きい
Dim greaterThan As Boolean = (x > y) ' False
' 以上
Dim greaterOrEqual As Boolean = (x >= y) ' False
論理演算子
Dim a As Boolean = True
Dim b As Boolean = False
' AND(論理積:両方Trueの場合のみTrue)
Dim resultAnd As Boolean = a And b ' False
Dim resultAndAlso As Boolean = a AndAlso b ' False(短絡評価)
' OR(論理和:どちらかがTrueならTrue)
Dim resultOr As Boolean = a Or b ' True
Dim resultOrElse As Boolean = a OrElse b ' True(短絡評価)
' NOT(否定)
Dim resultNot As Boolean = Not a ' False
' XOR(排他的論理和)
Dim resultXor As Boolean = a Xor b ' True
AndAlso と OrElse: 短絡評価を行います。左側の条件で結果が確定したら、右側を評価しません。
文字列演算子
' 連結(&)
Dim firstName As String = "太郎"
Dim lastName As String = "山田"
Dim fullName As String = lastName & firstName ' "山田太郎"
' 連結(+も使えるが&推奨)
Dim message As String = "Hello " + "World"
条件分岐
If文
基本的な条件分岐です。
基本構文:
If 条件式 Then
' 条件がTrueの時の処理
End If
例:
Dim age As Integer = 20
If age >= 20 Then
Console.WriteLine("成人です")
End If
If…Else文
Dim age As Integer = 18
If age >= 20 Then
Console.WriteLine("成人です")
Else
Console.WriteLine("未成年です")
End If
If…ElseIf…Else文
Dim score As Integer = 75
If score >= 80 Then
Console.WriteLine("優")
ElseIf score >= 60 Then
Console.WriteLine("良")
ElseIf score >= 40 Then
Console.WriteLine("可")
Else
Console.WriteLine("不可")
End If
1行If文
' 簡単な条件なら1行で書ける
If age >= 20 Then Console.WriteLine("成人です")
' 三項演算子のような書き方
Dim message As String = If(age >= 20, "成人", "未成年")
Select Case文
複数の条件を比較する場合は、Select Case の方が読みやすくなります。
基本構文:
Select Case 変数
Case 値1
' 処理1
Case 値2
' 処理2
Case Else
' どれにも当てはまらない場合
End Select
例:
Dim dayOfWeek As Integer = 3
Select Case dayOfWeek
Case 1
Console.WriteLine("月曜日")
Case 2
Console.WriteLine("火曜日")
Case 3
Console.WriteLine("水曜日")
Case 4
Console.WriteLine("木曜日")
Case 5
Console.WriteLine("金曜日")
Case 6, 7
Console.WriteLine("週末")
Case Else
Console.WriteLine("不正な値")
End Select
範囲指定のSelect Case
Dim score As Integer = 75
Select Case score
Case 80 To 100
Console.WriteLine("優")
Case 60 To 79
Console.WriteLine("良")
Case 40 To 59
Console.WriteLine("可")
Case 0 To 39
Console.WriteLine("不可")
Case Else
Console.WriteLine("範囲外")
End Select
条件式を使ったSelect Case
Dim age As Integer = 25
Select Case True
Case age < 13
Console.WriteLine("子供")
Case age < 20
Console.WriteLine("未成年")
Case age < 60
Console.WriteLine("成人")
Case Else
Console.WriteLine("高齢者")
End Select
ループ処理
For…Next文
指定回数の繰り返し処理を行います。
基本構文:
For カウンタ変数 = 開始値 To 終了値 Step 増減値
' 繰り返す処理
Next
例:
' 1から10まで表示
For i As Integer = 1 To 10
Console.WriteLine(i)
Next
' 0から100まで10ずつ増やす
For i As Integer = 0 To 100 Step 10
Console.WriteLine(i)
Next
' 10から1まで減らす
For i As Integer = 10 To 1 Step -1
Console.WriteLine(i)
Next
For Each…Next文
配列やコレクションの要素を順番に処理します。
基本構文:
For Each 変数 In コレクション
' 処理
Next
例:
' 配列の要素を順番に表示
Dim fruits() As String = {"りんご", "バナナ", "みかん"}
For Each fruit As String In fruits
Console.WriteLine(fruit)
Next
' リストの要素を処理
Dim numbers As New List(Of Integer) From {1, 2, 3, 4, 5}
For Each num As Integer In numbers
Console.WriteLine(num * 2)
Next
While…End While文
条件がTrueの間、繰り返します。
基本構文:
While 条件式
' 繰り返す処理
End While
例:
Dim count As Integer = 0
While count < 5
Console.WriteLine(count)
count += 1
End While
Do…Loop文
いくつかのバリエーションがあります。
Do While…Loop(前判定):
Dim count As Integer = 0
Do While count < 5
Console.WriteLine(count)
count += 1
Loop
Do…Loop While(後判定):
Dim count As Integer = 0
Do
Console.WriteLine(count)
count += 1
Loop While count < 5
Do Until…Loop(前判定、条件がFalseの間繰り返す):
Dim count As Integer = 0
Do Until count >= 5
Console.WriteLine(count)
count += 1
Loop
Do…Loop Until(後判定、条件がFalseの間繰り返す):
Dim count As Integer = 0
Do
Console.WriteLine(count)
count += 1
Loop Until count >= 5
Exit文とContinue文
Exit For / Exit While: ループを途中で抜ける
For i As Integer = 1 To 10
If i = 5 Then
Exit For ' ループを抜ける
End If
Console.WriteLine(i)
Next
' 1, 2, 3, 4が表示される
Continue For / Continue While: 現在の繰り返しをスキップ
For i As Integer = 1 To 5
If i = 3 Then
Continue For ' 3をスキップ
End If
Console.WriteLine(i)
Next
' 1, 2, 4, 5が表示される
配列
1次元配列
宣言と初期化:
' 方法1:サイズを指定して宣言
Dim numbers(4) As Integer ' 0から4までの5要素
' 方法2:初期値を指定
Dim numbers() As Integer = {1, 2, 3, 4, 5}
' 方法3:型推論
Dim numbers = {1, 2, 3, 4, 5}
' 方法4:Newを使う
Dim numbers As Integer() = New Integer(4) {}
要素へのアクセス:
Dim fruits() As String = {"りんご", "バナナ", "みかん"}
' 要素の取得
Console.WriteLine(fruits(0)) ' "りんご"
Console.WriteLine(fruits(1)) ' "バナナ"
' 要素の変更
fruits(0) = "いちご"
' 配列の長さ
Console.WriteLine(fruits.Length) ' 3
2次元配列
' 宣言
Dim matrix(2, 3) As Integer ' 3行4列
' 初期化付き宣言
Dim matrix(,) As Integer = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
}
' 要素へのアクセス
Console.WriteLine(matrix(0, 0)) ' 1
Console.WriteLine(matrix(1, 2)) ' 6
' ネストしたループで処理
For i As Integer = 0 To matrix.GetUpperBound(0)
For j As Integer = 0 To matrix.GetUpperBound(1)
Console.Write(matrix(i, j) & " ")
Next
Console.WriteLine()
Next
動的配列(List)
要素数が変わる場合は List を使います。
' リストの作成
Dim numbers As New List(Of Integer)
' 要素の追加
numbers.Add(10)
numbers.Add(20)
numbers.Add(30)
' 初期値を指定
Dim fruits As New List(Of String) From {"りんご", "バナナ", "みかん"}
' 要素の取得
Console.WriteLine(fruits(0)) ' "りんご"
' 要素の削除
fruits.Remove("バナナ")
fruits.RemoveAt(0) ' インデックス指定
' 要素数
Console.WriteLine(fruits.Count)
' 要素の検索
If fruits.Contains("みかん") Then
Console.WriteLine("みかんがあります")
End If
' すべての要素をクリア
fruits.Clear()
関数とサブルーチン
Sub(サブルーチン)
戻り値がない処理をまとめます。
基本構文:
Sub サブルーチン名(パラメータ)
' 処理
End Sub
例:
' パラメータなし
Sub SayHello()
Console.WriteLine("こんにちは")
End Sub
' パラメータあり
Sub Greet(ByVal name As String)
Console.WriteLine($"こんにちは、{name}さん")
End Sub
' 複数のパラメータ
Sub DisplayInfo(ByVal name As String, ByVal age As Integer)
Console.WriteLine($"{name}さんは{age}歳です")
End Sub
' 呼び出し
SayHello()
Greet("太郎")
DisplayInfo("太郎", 25)
Function(関数)
戻り値がある処理をまとめます。
基本構文:
Function 関数名(パラメータ) As 戻り値の型
' 処理
Return 戻り値
End Function
例:
' 簡単な関数
Function Add(ByVal a As Integer, ByVal b As Integer) As Integer
Return a + b
End Function
' 使用例
Dim result As Integer = Add(10, 20)
Console.WriteLine(result) ' 30
' 文字列を返す関数
Function GetGreeting(ByVal name As String) As String
Return $"こんにちは、{name}さん"
End Function
Console.WriteLine(GetGreeting("太郎"))
' 複雑な処理の例
Function GetGrade(ByVal score As Integer) As String
If score >= 80 Then
Return "優"
ElseIf score >= 60 Then
Return "良"
ElseIf score >= 40 Then
Return "可"
Else
Return "不可"
End If
End Function
Console.WriteLine(GetGrade(75)) ' "良"
引数の渡し方
ByVal(値渡し): 値のコピーを渡す(デフォルト)
Sub ChangeValue(ByVal x As Integer)
x = 100 ' xを変更しても、元の変数は変わらない
End Sub
Dim num As Integer = 10
ChangeValue(num)
Console.WriteLine(num) ' 10(変わらない)
ByRef(参照渡し): 変数そのものを渡す
Sub ChangeValue(ByRef x As Integer)
x = 100 ' 元の変数も変わる
End Sub
Dim num As Integer = 10
ChangeValue(num)
Console.WriteLine(num) ' 100(変わる)
Optional(省略可能なパラメータ)
Function Greet(ByVal name As String, Optional ByVal title As String = "さん") As String
Return $"こんにちは、{name}{title}"
End Function
' 使用例
Console.WriteLine(Greet("太郎")) ' "こんにちは、太郎さん"
Console.WriteLine(Greet("太郎", "様")) ' "こんにちは、太郎様"
ParamArray(可変長引数)
Function Sum(ByVal ParamArray numbers() As Integer) As Integer
Dim total As Integer = 0
For Each num As Integer In numbers
total += num
Next
Return total
End Function
' 使用例
Console.WriteLine(Sum(1, 2, 3)) ' 6
Console.WriteLine(Sum(10, 20, 30, 40)) ' 100
クラスとオブジェクト
クラスの定義
' クラスの定義
Public Class Person
' プロパティ(フィールド)
Public Name As String
Public Age As Integer
' コンストラクタ
Public Sub New()
Name = "名無し"
Age = 0
End Sub
Public Sub New(ByVal name As String, ByVal age As Integer)
Me.Name = name
Me.Age = age
End Sub
' メソッド
Public Sub Introduce()
Console.WriteLine($"私の名前は{Name}、{Age}歳です")
End Sub
Public Function IsAdult() As Boolean
Return Age >= 20
End Function
End Class
クラスの使用
' インスタンスの作成
Dim person1 As New Person()
person1.Name = "太郎"
person1.Age = 25
' パラメータ付きコンストラクタ
Dim person2 As New Person("花子", 30)
' メソッドの呼び出し
person1.Introduce() ' "私の名前は太郎、25歳です"
person2.Introduce() ' "私の名前は花子、30歳です"
' 関数の呼び出し
If person1.IsAdult() Then
Console.WriteLine("成人です")
End If
プロパティ
Public Class Product
' プライベートフィールド
Private _price As Decimal
' プロパティ(自動実装)
Public Property Name As String
Public Property Category As String
' プロパティ(完全版)
Public Property Price As Decimal
Get
Return _price
End Get
Set(value As Decimal)
If value < 0 Then
Throw New ArgumentException("価格は0以上である必要があります")
End If
_price = value
End Set
End Property
' 読み取り専用プロパティ
Public ReadOnly Property TaxIncludedPrice As Decimal
Get
Return _price * 1.1
End Get
End Property
End Class
' 使用例
Dim product As New Product()
product.Name = "ノートPC"
product.Category = "電化製品"
product.Price = 100000
Console.WriteLine($"{product.Name}: {product.TaxIncludedPrice}円")
エラーハンドリング
Try…Catch…Finally
Try
' エラーが発生する可能性のある処理
Dim result As Integer = 10 / 0 ' ゼロ除算エラー
Catch ex As DivideByZeroException
' 特定のエラーをキャッチ
Console.WriteLine("ゼロで割ることはできません")
Catch ex As Exception
' すべてのエラーをキャッチ
Console.WriteLine($"エラーが発生しました: {ex.Message}")
Finally
' 必ず実行される処理(クリーンアップなど)
Console.WriteLine("処理を終了します")
End Try
複数のCatch
Try
Dim numbers() As Integer = {1, 2, 3}
Console.WriteLine(numbers(10)) ' 範囲外エラー
Catch ex As IndexOutOfRangeException
Console.WriteLine("配列の範囲外です")
Catch ex As NullReferenceException
Console.WriteLine("オブジェクトが存在しません")
Catch ex As Exception
Console.WriteLine($"予期しないエラー: {ex.Message}")
End Try
Throw(例外を投げる)
Function Divide(ByVal a As Integer, ByVal b As Integer) As Double
If b = 0 Then
Throw New ArgumentException("ゼロで割ることはできません", "b")
End If
Return a / b
End Function
' 使用例
Try
Dim result As Double = Divide(10, 0)
Catch ex As ArgumentException
Console.WriteLine(ex.Message)
End Try
よく使う便利な構文
文字列操作
Dim text As String = "Hello, World!"
' 長さ
Console.WriteLine(text.Length) ' 13
' 大文字・小文字変換
Console.WriteLine(text.ToUpper()) ' "HELLO, WORLD!"
Console.WriteLine(text.ToLower()) ' "hello, world!"
' 部分文字列
Console.WriteLine(text.Substring(0, 5)) ' "Hello"
' 文字列の検索
Console.WriteLine(text.IndexOf("World")) ' 7
Console.WriteLine(text.Contains("World")) ' True
' 文字列の置換
Console.WriteLine(text.Replace("World", "VB")) ' "Hello, VB!"
' 分割
Dim words() As String = text.Split(","c)
For Each word As String In words
Console.WriteLine(word.Trim())
Next
' 前後の空白削除
Dim text2 As String = " Hello "
Console.WriteLine(text2.Trim()) ' "Hello"
' 文字列が空かチェック
If String.IsNullOrEmpty(text) Then
Console.WriteLine("空です")
End If
日付操作
' 現在の日付と時刻
Dim now As DateTime = DateTime.Now
Dim today As Date = Date.Today
' 日付の加算・減算
Dim tomorrow As Date = today.AddDays(1)
Dim lastMonth As Date = today.AddMonths(-1)
Dim nextYear As Date = today.AddYears(1)
' 日付の書式化
Console.WriteLine(now.ToString("yyyy/MM/dd")) ' 2025/12/08
Console.WriteLine(now.ToString("yyyy年MM月dd日")) ' 2025年12月08日
Console.WriteLine(now.ToString("HH:mm:ss")) ' 14:30:45
' 日付の比較
Dim date1 As Date = #2025/12/8#
Dim date2 As Date = #2025/12/9#
If date1 < date2 Then
Console.WriteLine("date1の方が古い")
End If
' 日数の差
Dim diff As TimeSpan = date2 - date1
Console.WriteLine($"{diff.Days}日の差")
型変換
' 数値 → 文字列
Dim num As Integer = 123
Dim str As String = num.ToString()
' 文字列 → 数値
Dim str2 As String = "456"
Dim num2 As Integer = Integer.Parse(str2)
' 安全な変換(失敗したらFalse)
Dim num3 As Integer
If Integer.TryParse("789", num3) Then
Console.WriteLine($"変換成功: {num3}")
Else
Console.WriteLine("変換失敗")
End If
' キャスト
Dim d As Double = 3.14
Dim i As Integer = CInt(d) ' 3
' 型変換関数
Dim result1 As Integer = CInt("123")
Dim result2 As Double = CDbl("3.14")
Dim result3 As String = CStr(456)
Dim result4 As Boolean = CBool(1) ' True
With文
' オブジェクトのプロパティを連続して設定
Dim person As New Person()
With person
.Name = "太郎"
.Age = 25
.Introduce()
End With
Using文(リソース管理)
' ファイルの読み書きなど、リソースを自動的に解放
Using reader As New StreamReader("file.txt")
Dim content As String = reader.ReadToEnd()
Console.WriteLine(content)
End Using ' ここで自動的にreader.Close()が呼ばれる
まとめ
VB.NETの基本構文を網羅的に解説しました。
重要なポイント:
- 変数と定数
Dimで変数宣言Constで定数宣言- 型推論も使える
- データ型
- 数値型:
Integer、Double、Decimalなど - 文字列型:
String - 論理型:
Boolean - 日付型:
Date/DateTime
- 演算子
- 算術:
+、-、*、/、\、Mod - 比較:
=、<>、<、>、<=、>= - 論理:
And、Or、Not、AndAlso、OrElse
- 条件分岐
If...Then...Else:基本的な分岐Select Case:複数の条件比較
- ループ
For...Next:回数指定For Each...Next:コレクション処理While...End While:条件付き繰り返しDo...Loop:様々なバリエーション
- 配列とコレクション
- 配列:固定サイズ
List:動的サイズ
- 関数とサブルーチン
Sub:戻り値なしFunction:戻り値ありByValとByRef
- クラスとオブジェクト
- クラス定義
- プロパティとメソッド
- コンストラクタ
- エラーハンドリング
Try...Catch...Finally
VB.NETの特徴(再確認):
- セミコロン不要
- 中括弧不要
- 読みやすい英語のような構文
- Visual Studioで効率的に開発
- .NET Frameworkの全機能が使える
この記事で紹介した構文をマスターすれば、VB.NETでの基本的なプログラミングができるようになります。実際に手を動かしてコードを書きながら、少しずつ理解を深めていきましょう。
次のステップ:
- Windows Formsアプリケーションの作成
- データベース接続(ADO.NET)
- ファイル入出力
- オブジェクト指向プログラミングの深掘り
頑張ってください!


コメント