我正在創建一個DnD角色創建程序,並且我已經陷入了「體驗/級別」區域。我想要的是每1000個經驗,水平上升(所以0到999是0級,如何創建體驗/升級系統?
所以,我用下面的代碼來得到我在哪裏,但它不會改變標籤(lblLevel)爲1時(當經驗更改爲2000或2)經驗(txtExperience)更改爲1000。
Private Sub txtExperience_textChanged(sender As Object, e As EventArgs) Handles txtExperience.TextChanged
If txtExperience.Text = letters Then
lblLevel.Text = "0"
ElseIf txtExperience.Text >= 10000 Then
lblLevel.Text = "Maxed"
End If
Select Case txtExperience.Text
Case Is <= "999"
lblLevel.Text = "0"
Case "1000" To "1999"
lblLevel.Text = "1"
Case "2000" To "2999"
lblLevel.Text = "2"
Case "3000" To "3999"
lblLevel.Text = "3"
Case "4000" To "4999"
lblLevel.Text = "4"
Case "5000" To "5999"
lblLevel.Text = "5"
Case "6000" To "6999"
lblLevel.Text = "6"
Case "7000" To "7999"
lblLevel.Text = "7"
Case "8000" To "8999"
lblLevel.Text = "8"
Case "9000" To "9999"
lblLevel.Text = "9"
End Select
End Sub
我會說實話,我不知道如果我在使用選擇案例...正確的,當我嘗試使用If語句(和其他情況下,如果就位的每個案例... ...),它也不會工作任何幫助將不勝感激
字符串是不是數字。 「9」將評估爲大於「1000」。打開Option Strict並使用數字(整數) – Plutonix
文本爲文本。你無法將其與數字進行比較。首先用'Integer.Parse()'或'Integer.TryParse()'解析文本,你會得到一個你可以比較的數字。 –