Results 1 to 4 of 4

Thread: Problem in my loop

  1. #1
    sara fisher is offline Member
    Join Date
    Jun 2009
    Posts
    30
    Rep Power
    0

    Default Problem in my loop

    Hello everyone,

    I'm having a difficulty in the following condition:


    '------------------------ Check only one field is filled ----------------- ---


    If NumAudit = "" And DriverName = "" Or NumAudit <> "" And DriverName <> "" Then
    MsgBox ( "Please do not fill a single field!")

    '- Empty Fields ------
    NumAudit.Clear
    NomPilote.Clear

    Else
    MsgBox ( "Ok")
    End If

    I want to spend the next instruction only if one of the 2 field is filled.

    Thank you for your help

  2. #2
    stephen flintoff is offline Junior Member
    Join Date
    Jun 2009
    Posts
    27
    Rep Power
    0

    Default

    just put one or exclusive:

    If NumAudit <> "" xor DriverName <> "" then.

    In this case, only if one of the two fields is completed, it will pass through the loop.

  3. #3
    sara fisher is offline Member
    Join Date
    Jun 2009
    Posts
    30
    Rep Power
    0

    Default

    I modified the macro with xor:

    If NumAudit = "" And DriverName = "" Xor NumAudit <> "" And DriverName <> "" Then
    MsgBox ( "Please do not fill a single field!")

    '- Empty Fields ------
    NumAudit.Clear
    NomPilote.Clear


    Else
    MsgBox ( "Ok")
    End If

    Call Select_Auditeur

    But if for example I filled the fields or that 2 is empty when it passes mm to the next instruction.

    Thank you

  4. #4
    stephen flintoff is offline Junior Member
    Join Date
    Jun 2009
    Posts
    27
    Rep Power
    0

    Default

    You do not need to do all that, the simple condition NumAudit <> "" xor DriverName <> "" enough, basically it will give you:

    Code:
    1.	If NumAudit <> "" xor DriverName <> "" then
    2.	MsgBox ( "Please do not fill a single field!")
    3.	
    4.	'- Empty Fields ------
    5.	NumAudit.Clear
    6.	NomPilote.Clear
    7.	
    8.	
    9.	Else
    10.	MsgBox ( "Ok")
    11.	End If
    12.	
    13.	Call Select_Auditeur

Similar Threads

  1. outer loop in C
    By ashley_black in forum Programming
    Replies: 1
    Last Post: 03-12-2010, 12:05 PM
  2. Java for loop example
    By WilsonMartin in forum Programming
    Replies: 1
    Last Post: 02-10-2010, 01:12 PM
  3. Differentiate between Do-While loop and While loop
    By RussellBarnes in forum Programming
    Replies: 1
    Last Post: 01-14-2010, 06:27 PM
  4. XP Installation Loop
    By iban555 in forum Windows XP
    Replies: 2
    Last Post: 04-29-2009, 11:31 AM
  5. using The Loop Function
    By jack879 in forum Everything Else
    Replies: 0
    Last Post: 11-17-2008, 12:45 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48