0
Dim charArray() As Char = randomWord.ToCharArray 'Splits the selected words into individuals strings in a array
Letter1.Text = charArray(0) ' Changes each label into its corresponding character from array
Letter2.Text = charArray(1) '*
Letter3.Text = charArray(2) '*
Letter4.Text = charArray(3) '*
Letter5.Text = charArray(4) '*
If randomWord.Contains(answer) Then 'if random word contains the users input
MessageBox.Show("You are correct!")
Correctcounter()
winorLoss = "won"
highScore()
Userinput()
我設置了5個標籤,每個標籤對應於5個字母的字符。我正在尋找一種方法,如果用戶輸入(變量 答案)出現在變量randomWord中,則變量randomWord中的相應單詞將被設置爲相應的Letter.text。因此,如果用戶輸入是單詞「多汁」中出現的「j」,則第一個標籤變爲表示「J」。抱歉格式不佳。字符串中的對應字母
'String.IndexOf'會告訴你某個字母或子字符串在哪裏,但是在該代碼中不是J已經在Letter1中顯示? – Plutonix
我忘了添加變量randomWord,它將包含「juicy」,在數組中循環並選擇單詞,所以單詞可能不是多汁,它可以是「hello」或「goodbye」例如「因此它會顯示j但它不會與其他詞的工作。 – AESTHETIC
會發生什麼,如果池包含JUICY和班卓琴?你顯示它在兩個地方?'String.IndexOf'會告訴你,如果它包含一個字母,如果是的話,在這裏 – Plutonix