Results 1 to 12 of 12

Thread: Best Logic to solve this

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Best Logic to solve this

    Hi,

    I have little logic problem here
    It's like this.
    I have 4 textbox :Text1, Text2, Text3, Text4
    At start Text1 enabled is true, other are false.
    When user fill data to Text1 and the data entry get validate is true, Text2 enabled set to true and so on with Text3 and Text4.

    When user corrected data entry on Text2 and the data entry get validate is false, Text3, Text4 enabled property set to false but the value remain.

    When user corrected data entry on Text1 and the data entry get validate is false, Text2, Text3, Text4 enabled property set to false but the value remain.

    And so on.

    Hope you all got my message.

  2. #2
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Best Logic to solve this

    where do you get the validation value?
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Best Logic to solve this

    I would suggest useing the Lost_Focus() Event of each TextBox to validate the data. IE. Initiating as a result of pressing a CommandButton.

    If the Text1_LostFocus() event validates the data, then disable, and enable TextBox2 etc....

    And.... use a Control Array of TextBox's too

  4. #4
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Best Logic to solve this

    i agree
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Best Logic to solve this

    Seems like you are correctly disabling the textboxes but you are not removing its contents, so each time you disable a textbox empty its .Text property: text2.text = VbNullString

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Best Logic to solve this

    Eg:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Text1_LostFocus(Index As Integer)
    4.  
    5.     If IsNumeric(Text1(Index).Text) Then
    6.         'Do something
    7.         Text1(Index).Enabled = False
    8.         If Index < Text1.Count - 1 Then Text1(Index + 1).Enabled = True
    9.     Else
    10.         'Data entry error
    11.         Text1(Index).SetFocus
    12.         MsgBox "Please enter xxxxxx.", vbOKOnly + vbInformation, "Data Entry Error!"
    13.     End If
    14.  
    15. End Sub
    Last edited by Bruce Fox; Jul 31st, 2006 at 11:38 PM.

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Best Logic to solve this

    Quote Originally Posted by jcis
    Seems like you are correctly disabling the textboxes but you are not removing its contents, so each time you disable a textbox empty its .Text property: text2.text = VbNullString

    I take care of that in my example above, by re focusing until the data is correct.

  8. #8
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Best Logic to solve this

    VB Code:
    1. Option Explicit
    2.  
    3. Dim intTBCount As Integer
    4.  
    5. Private Sub Form_Load()
    6. Dim intIdx As Integer
    7.  
    8.     intTBCount = Text1.Count - 1
    9.  
    10.     For intIdx = 1 To intTBCount  'Skip the first TextBox
    11.         Text1(intIdx).Enabled = False
    12.     Next
    13.    
    14. End Sub
    15.  
    16. Private Sub Text1_LostFocus(Index As Integer)
    17.  
    18.     If IsNumeric(Text1(Index).Text) Then
    19.         'Do something
    20.         Text1(Index).Enabled = False
    21.         If Index < intTBCount Then Text1(Index + 1).Enabled = True
    22.     Else
    23.         'Data entry error
    24.         Text1(Index).SetFocus
    25.         Text1(Index).SelStart = 0
    26.         Text1(Index).SelLength = Len(Text1(Index).Text)
    27.         MsgBox "Please enter xxxxxx.", vbOKOnly + vbInformation, "Data Entry Error!"
    28.     End If
    29.  
    30. End Sub

    Or alternatly, using the Validate Event:
    VB Code:
    1. Option Explicit
    2.  
    3. Dim intTBCount As Integer
    4.  
    5. Private Sub Form_Load()
    6. Dim intIdx As Integer
    7.  
    8.     intTBCount = Text1.Count - 1
    9.  
    10.     For intIdx = 1 To intTBCount  'Skip the first TextBox
    11.         Text1(intIdx).Enabled = False
    12.     Next
    13.    
    14. End Sub
    15.  
    16. Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
    17.  
    18.     If IsNumeric(Text1(Index).Text) Then
    19.         'Do something
    20.         Text1(Index).Enabled = False
    21.         If Index < intTBCount Then Text1(Index + 1).Enabled = True
    22.     Else
    23.         'Data entry error
    24.         Cancel = True
    25.         MsgBox "Please enter xxxxxx.", vbOKOnly + vbInformation, "Data Entry Error!"
    26.     End If
    27.    
    28. End Sub
    Last edited by Bruce Fox; Aug 1st, 2006 at 10:39 PM.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Best Logic to solve this

    is there any generic solution other than using array textbox when another control frame of combobox?

  10. #10
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Best Logic to solve this

    Quote Originally Posted by barianto
    is there any generic solution other than using array textbox when another control frame of combobox?
    And how does that relate to your subject post??????

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Best Logic to solve this

    sorry,
    I just found out that i need using frame

  12. #12
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Best Logic to solve this

    And ComboBoxs or TextBox's......????

    Also, for what it's worth, I added similar code (above) to validate using the TextBox Validate() Event - setting Cancel = True.
    Last edited by Bruce Fox; Aug 1st, 2006 at 10:42 PM.

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