Results 1 to 2 of 2

Thread: Move to Next Check If

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2011
    Posts
    50

    Move to Next Check If

    I have 5 textboxes and a button which once clicked I would like it to check textbox1.text and if there is the value "11" in it then change it to 1.

    Once clicked again if there is the value "11" in textbox2.text also change it to 1

    Once clicked again check textbox3.text if it has "11" change it to 1

    Once clicked again check textbox4.text if it has "11" change it to 1

    so on so forth

    Thanks in advance

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Move to Next Check If

    Try this:
    vb.net Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.     Static i As Integer = 0
    3.     Dim textBoxes() As TextBox = {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5}
    4.     If i < textBoxes.Length Then
    5.         If textBoxes(i).Text = "" Then textBoxes(i).Text = "1"
    6.         i += 1
    7.     End If
    8. End Sub
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width