Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

vb looping..here we go again

  • 10-01-2003 10:35pm
    #1
    Closed Accounts Posts: 1,152 ✭✭✭


    right..after many hours pulling my hair out..i have the following problem concerning an input box and looping..

    the prob is as follows:

    i have a text box where the user must enter a telephone number, if s/he enters it wrong 3 times then the form resets..so , i check the value in the textbox using the IsNumeric function and using an if...then statement i begin the loop..however if i enter a non numeric , which results in a message box popping up and notifying the user that the date must be numeric..then if i enter numeric data into the input box the data enters the textbox but the input box pops up again..and again and again until the loop finishes and resets the form...

    :(
    as i said i really have tried everything with this..

    any help, even minimal would be greatly appreciated,

    thanks


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    You're probably overcomplicating your nested loop logic. Keep it as simple as possible. Something like:
    Private Sub Command1_Click()
        Static iAttempt As Integer
        
        If IsNumeric(Text1.Text) Then
            'Number is Valid - Do Stuff
        Else
            iAttempt = iAttempt + 1
            MsgBox "Numeric value needed!"
        End If
        
        If iAttempt = 3 Then
            iAttempt = 0
            'Reset after 3 attemps - Do Stuff
        End If
    End Sub
    


  • Closed Accounts Posts: 1,152 ✭✭✭sound_wave


    right... but if the value in the inputbox is true how do i write the code so this value is stored in the property of the textbox

    is it...
    dim intAtempt as integer

    for intAttempt = 0 to 2

    if isNumeric(txtNumber.text) = true then
    txtNumber.text = inputbox.text (i know this is wrong but i dont know what to do)
    else
    msgbox "Data must be numeric" , vbExclamation, "Incorrect Data"
    txtNumber.text = " "

    end if

    Next intAttempt


    is this correct apart from the issue concerning the inputbox?
    thanks


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Originally posted by sound_wave
    txtNumber.text = inputbox.text (i know this is wrong but i dont know what to do)
    You check the help files that come with VB, MSDN and Google for a tutorial to show you how, ffs.


  • Closed Accounts Posts: 1,152 ✭✭✭sound_wave


    help files didnt come with the version i have of vb here at home..i only got a working edition..will do
    thanks


  • Closed Accounts Posts: 1,152 ✭✭✭sound_wave


    not to worry figured it out...had to use an exit for statement is the nested if..then statement thanks for all the help Corinthian must appreciated!!:)
    thanks


  • Advertisement
Advertisement