これは奇妙な要求です。 Windowsフォーム上のボタンがあれば、あなたが望むことをするためのコードは以下の通りです。 "a"を実際の入力に置き換えてください。
ランダムな単語の生成とその文字の実際のテストを2つの別々の部分に分割することを検討してください。
幸運
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim randomWord As String = GetRandomWord()
Dim userInput As Char = "a"
If randomWord.Contains(userInput) Then
MessageBox.Show("Yes, the word '" + randomWord + "' DOES contain the letter '" + userInput + "'")
Else
MessageBox.Show("No, the word '" + randomWord + "' DOES NOT contain the letter '" + userInput + "'")
End If
End Sub
Private Function GetRandomWord() As String
Dim listWords(4) As String
listWords(0) = "juicy"
listWords(1) = "aaron"
listWords(2) = "power"
listWords(3) = "weigh"
listWords(4) = "public"
Dim Index As Integer = GetRandomNumber(listWords.Length - 1)
Return listWords(Index)
End Function
Private Function GetRandomNumber(maxValue As Integer) As Integer
'Math.Ceiling rounds up to the nearest whole number
Return Math.Ceiling(Rnd() * maxValue)
End Function
End Class
VBA私は、ビジュアル・スタジオを使用しています。 – AESTHETIC
@ScottCranerの質問に対するあなたの答えは意味をなさない。おそらく、あなたはVBAとVB.Netの違いを知らないでしょう。後者を使用しています。 –
私はかなり新しいので、私は違いを認識していないようです。 – AESTHETIC