dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] problem with repeated msgboxes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2015
    Posts
    421

    Resolved [RESOLVED] problem with repeated msgboxes

    Hello progtrammers
    I'm using this code to loop through a listview items and send a message in case of entering wrong values.
    Code:
    For I = 1 To ListView1.ListItems.count
    If Val(ListView1.ListItems(I)) < 2 Or Val(ListView1.ListItems(I)) > 5 Then MsgBox "wrong values" 
    Next
    my trouble is that I can't avoid repeated messages in case there are more than one wrong value entered.
    Exampe: If there are 2 values under 2 and 3 values bigger than 5, I'll get 5 msboxes.
    Thank you

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: problem with repeated msgboxes

    Use Exit For
    Code:
    For I = 1 To ListView1.ListItems.count
        If Val(ListView1.ListItems(I)) < 2 Or Val(ListView1.ListItems(I)) > 5 Then 
            MsgBox "wrong values" 
            Exit For
        End If
    Next

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2015
    Posts
    421

    Re: problem with repeated msgboxes

    thanks a lot sir
    solved

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width