2011-02-13 5 views
0

저는 VB에서 새롭고 숙제를하고 있습니다. 마술 상자가 있어야합니다. 9 개의 텍스트 상자에 9 개의 숫자를 넣고, 그렇지 않은지 확인해야합니다. TextChanged 이벤트도 마찬가지입니다.VB의 모든 텍스트 상자를 확인하십시오.

코드가 있지만 불완전합니다. 그리고 실제로 작동하지 않습니다.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
TextBox1.TextChanged, 
TextBox2.TextChanged, 
TextBox2.TextChanged, 
TextBox3.TextChanged, 
TextBox4.TextChanged, 
TextBox5.TextChanged, 
TextBox6.TextChanged, 
TextBox7.TextChanged, 
TextBox8.TextChanged, 
TextBox9.TextChanged 

If Not (IsNumeric(TextBox1.Text)) 
Then 
MsgBox("ERROR") 
End If 
Dim a As Integer 

End Sub 
+0

코드를 게시 할 수 있습니까? –

+0

그것은 나를 많이 보내지 않는다. (( – itsmedavid

답변

1

폼에 명령 단추를 추가 ... 그리고 거기에 코드를 넣습니다 ..

사용 조건 문

If textbox1 <> texbox2 or textbox3 <> texbox4 then 
MsgBox "We are not equal" 
Else 
MsgBox "We are equal" 

감사합니다 .. 다른 경우처럼!

+0

) 나는 그것의 여물을 보았지만 쉽다. 그러나 나는 우리가 더 이상 쉬운 방법을 궁금해하고있는 많은 쓸모없는 코드가 될 것 같은 9 개의 텍스트 박스를 말하고있다. – itsmedavid

+0

코드 @itsmedavid를 게시 할 수 있습니까? – Crimsonland

+0

'code' Private Sub TextBox1_TextChanged (ByVal 보낸 사람 System.Object, ByVal e As System.EventArgs)는 TextBox1.TextChanged, TextBox2.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged, TextBox4.TextChanged를 처리합니다. , TextBox5.TextChanged는 TextBox6.TextChanged는 TextBox7.TextChanged, TextBox8.TextChanged는 TextBox9.TextChanged 하지 않을 경우 (ISNUMERIC (TextBox1.Text)) 다음 있는 MsgBox ("ERROR") 최종면 희미한 a를 정수 로 End Sub'code' – itsmedavid

0

다음 코드가 도움이된다고 생각합니다.

Private Sub btn_generate_text_array_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click 'button click will generate 10 text boxes in form 
      Dim j As Integer 
      For j = 0 To 10 
       ReDim Preserve c(j) 
       c(j) = New TextBox 
       c(j).Name = "txt" & j 
       c(j).Parent = Me 
       c(j).Top = j * c(j).PreferredHeight + 2 
       c(j).Tag = j 
       c(j).Visible = True 
      Next 
     End Sub 

     Private Sub btn_process_input_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
      For j = 0 To 10 
       For k = j + 1 To 10 
        If Val(c(j).Text) = Val(c(k).Text) Then 
'if identical values ware found then the back color of both the text boxes will turn to red 
         c(j).BackColor = Color.Red 
         c(k).BackColor = Color.Red 
         MsgBox("same values found") 
        End If 
       Next 
      Next 
     End Sub 
관련 문제