クラスの定義で
Function Operator== (lpszText As LPSTR) As Long
If lstrcmp(This, lpszText) = 0 Then Return TRUE
End Function
がありますが、
Dim a As String
a = "2"
If a == "1" Then
MsgBox 0, "test", "a", MB_OK
End If
End
このソースで文法エラーが発生します。
String Class比較演算
-
- 記事: 473
- 登録日時: 2005年5月31日(火) 18:51
- お住まい: 新潟県
Re: String Class比較演算
> このソースで文法エラーが発生します。
正しくは以下のように書きます。
正しくは以下のように書きます。
コード: 全て選択
Function Operator== (lpszText As LPSTR) As Long
If lstrcmp(This, lpszText) = 0 Then Return TRUE
End Function
Dim a As String
a = "2"
If a = "1" Then
MsgBox 0, "test", "a", MB_OK
End If
End
-
- 記事: 35
- 登録日時: 2005年5月31日(火) 09:39
- お住まい: 岐阜
-
- 記事: 35
- 登録日時: 2005年5月31日(火) 09:39
- お住まい: 岐阜
追加
今気づいたけどABでは IF は 0 以外は入るみたいで、
Not は、数値に対して '(数値 + 1) * (-1)' する関係で
こういうコードで見るとわかりやすいけど、
これは
このほうが、前の'String型'との互換性が強いかもしれません。
もしくはTRUEの数値を'-1'にするか・・・
Not は、数値に対して '(数値 + 1) * (-1)' する関係で
コード: 全て選択
If 0 Then
MsgBox 0, "test", "0", MB_OK '非表示
End If
If 1 Then
MsgBox 0, "test", "1", MB_OK '表示
End If
If -1 Then
MsgBox 0, "test", "-1", MB_OK '表示
End If
If Not(0) Then
MsgBox 0, "test", "Not(0)", MB_OK '表示
End If
If Not(1) Then
MsgBox 0, "test", "Not(1)", MB_OK '表示
End If
If Not(-1) Then
MsgBox 0, "test", "Not(-1)", MB_OK '非表示
End If
コード: 全て選択
Function Operator== (lpszText As LPSTR) As Long
If lstrcmp(This, lpszText) = 0 Then Return TRUE
End Function
コード: 全て選択
Function Operator== (lpszText As LPSTR) As Long
If lstrcmp(This, lpszText) = 0 Then Return -1
End Function
もしくはTRUEの数値を'-1'にするか・・・
-
- 記事: 264
- 登録日時: 2005年5月31日(火) 10:52
- お住まい: 高知
-
- 記事: 899
- 登録日時: 2005年5月31日(火) 17:59
- お住まい: 東京都