「VB.NET」関数(Function)に列挙型(enum)を使うサンプル
1.Enumの定義
列挙型(Enum型)の定義
[アクセス修飾子] Enum 名前 {
定数1 [=数値]
…
End Enum
定数の値は変更できません。
enum名前.定数でアクセスします。
使用例
Public Enum OPFLG
UPDATE = 0 '更新
DELETE = 1 '削除
INSERT = 1 '挿入
End Enum
Public Enum OPFLG
UPDATE = 0 '更新
DELETE = 1 '削除
INSERT = 1 '挿入
End Enum
Public Enum OPFLG UPDATE = 0 '更新 DELETE = 1 '削除 INSERT = 1 '挿入 End Enum
2.Functionの定義
関数(Function)の定義
Public Shared Function 関数名(ByVal 変数名 As String)
処理コード
End Function
Public Shared Function 関数名(ByVal 変数名 As String)
処理コード
End Function
Public Shared Function 関数名(ByVal 変数名 As String) 処理コード End Function
使用例
Public Shared Function GetFunc(ByVal Cft As String)
Dim strRes As String = ""
'If Then文
If Cft = CStr(OPFLG.UPDATE) Then
strRes = "更新依頼,"
ElseIf Cft = CStr(OPFLG.DELETE) Then
strRes = "削除依頼,"
End If
Return strRes
End Function
Public Shared Function GetFunc(ByVal Cft As String)
Dim strRes As String = ""
'If Then文
If Cft = CStr(OPFLG.UPDATE) Then
strRes = "更新依頼,"
ElseIf Cft = CStr(OPFLG.DELETE) Then
strRes = "削除依頼,"
End If
Return strRes
End Function
Public Shared Function GetFunc(ByVal Cft As String) Dim strRes As String = "" 'If Then文 If Cft = CStr(OPFLG.UPDATE) Then strRes = "更新依頼," ElseIf Cft = CStr(OPFLG.DELETE) Then strRes = "削除依頼," End If Return strRes End Function