-2
私はVB6で推測ゲームをしようとしています。それはユーザが入力した文字を比較することを含む。私はすでにそれを探しました、残念ながら、彼らは最新のバージョンを持っています。VB6でシングルチャーを比較するには?
誰でもVisual Basic 6.0の1つの文字を比較するのに役立ちます。なぜなら、率直に言って私はそれについて考えていないからです。
私はVB6で推測ゲームをしようとしています。それはユーザが入力した文字を比較することを含む。私はすでにそれを探しました、残念ながら、彼らは最新のバージョンを持っています。VB6でシングルチャーを比較するには?
誰でもVisual Basic 6.0の1つの文字を比較するのに役立ちます。なぜなら、率直に言って私はそれについて考えていないからです。
AscとChr $は、検索する関数です。
Private Sub Form_Load()
Dim lSecret As Long
Dim sInput As String
Dim lAscChar As Long
'Define a secret character as an ANSI code.
lSecret = Asc("m")
Do
'Let the user input a single character.
sInput = InputBox("Enter a single character. " & _
"If more characters are entered, only the first one " & _
"will be used. To end just click OK without entering text.")
If Len(sInput) = 0 Then Exit Sub
'Obtain the first character's ANSI code.
lAscChar = Asc(sInput)
'If the user entered the correct secret character, tell her.
'Otherwise give a hint.
If lSecret = lAscChar Then
MsgBox "Great, you are a hero."
Exit Sub
ElseIf lSecret < lAscChar Then
MsgBox "Nope, in the ANSI table, the correct answer is " & _
"before this one."
Else
MsgBox "Nope, in the ANSI table, the correct answer is " & _
"after this one."
End If
Loop
End Sub
文字列を比較するコードが見つかりませんでしたか? Googleはあなたの友人です。 VB6 – dbmitch
'Dim MySecretChar As String'で1回の文字列であなたの試行を共有しましょう。最も単純な比較は' If Text1.Text = MySecretChar Then MsgBox( "good") 'とすることができますそれ以外のコードスニペットでより多くの洞察を得ることができます... –