即時通訊使用Microsoft Visual工作室2012年做這個項目的一個在線測試在ASP.NET VB中的IM循環通過文本框和標籤
我試着去得到一個循環通過我的文本框會,並檢查他們對一個單詞本將被更改爲針對數據庫進行驗證以查看答案是否正確,但是當我執行循環時,我無法從文本框中獲取我的文本。
請參考下面
Private Sub GoGoGo()
Dim Textboxname As String '
Dim textbox As Object
Dim TextboxText As Object
Dim Labelname As String
Dim label As Object
Dim LabelText As Object
Dim Number As Integer = 1
Dim MaxTime As Integer = 9
Dim Currentloop As Integer = 1
For check As Integer = Currentloop To MaxTime
If Currentloop <= MaxTime Then
Textboxname = "TextQ" + Number
textbox = Textboxname
TextboxText = textbox
textbox.ReadOnly = True
End If
If Currentloop <= MaxTime Then
Labelname = "Label" + Number
label = Labelname
LabelText = label.Text
label.Visible = True
End If
Number = Number + 1
If TextboxText = "" Then
label.Text = "no imput"
label.ForeColor = Drawing.Color.Black
End If
If TextboxText = "server" Then
label.Text = "Correct"
label.ForeColor = Drawing.Color.Green
End If
If TextboxText = "Wrong" Then
label.Text = "Wrong"
label.ForeColor = Drawing.Color.Red
End If
If check = 9 Then
Exit For
End If
Next
End Sub
喜短跑代碼試試,我剛纔想了這一點,在oTextBox = CTYPE(頁。FindControl(「TextQ」+ Number),TextBox)即時獲取錯誤「從字符串」TextQ「轉換爲鍵入」Double「無效。我該怎麼做,並感謝您的幫助 – 2013-04-23 08:44:56
@BennjaminMiles自第一次回答以來,我已經稍微改變了答案。讓我知道你是怎麼辦的。然而,爲了解釋,'oTextBox = CType(Page.FindControl(「TextQ」&check),TextBox)'可能更合適。 – dash 2013-04-23 08:46:37
嗨破折號,我現在已經改變了代碼來檢查,因爲你已經說過了,但是這仍然會出現錯誤「從字符串」TextQ「轉換爲類型」Double「無效。親切的問候Benjamin Miles – 2013-04-23 09:01:37