if statement

if loop using yes/no dialogue

Page 1 of 1

2 Replies - 1152 Views - Last Post: 07 January 2011 - 11:34 AM Rate Topic: -----

#1 kadiaReid  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 24-April 10

if statement

Posted 07 January 2011 - 09:29 AM

hi
i'm using the if statement along with the yes/no message box. I have used some code that based on the value of certain fields will prompt the yes/no message box, however the no response works but the yes response doesn't function properly. when yes is selected it stays on the current form allowing you to select the activities but on clicking the proceed but again it prompts the yes/no message box and starts all over instead of taking you to the next form as the no response would. how can i make the yes response allow one to enter details before going to the next form.
 
 If AdultCanoeing.Value Or AdultTennis.Value Or AdultWaterSkiing.Value Or AdultWindSurfing.Value Or ChildCanoeing.Value Or ChildTennis.Value Or
       ChildWaterSkiing.Value Or ChildWindSurfing.Value Or InfantCreche.Value <= 0 Then
            Dim reply As DialogResult = MessageBox.Show(" No Extras selected, Do you want Extras", "", MessageBoxButtons.YesNo)
            If reply = DialogResult.No Then
                MsgBox("Proceeding to the next page")
                Form3.Visible = True
                ' ElseIf AdultCanoeing.Value Or AdultTennis.Value Or AdultWaterSkiing.Value Or AdultWindSurfing.Value Or ChildCanoeing.Value Or ChildTennis.Value Or
                ' ChildWaterSkiing.Value Or ChildWindSurfing.Value Or InfantCreche.Value > 0 Then
                '  Me.Hide()
            Else
                MsgBox("Choose activities")
                Form3.Visible = False
                Form3.Visible = True

                End If
            End If


        If ChildCanoeing.Value Or ChildTennis.Value Or ChildWaterSkiing.Value Or ChildWindSurfing.Value > Form1.NumericUpDownKids.Value And
      AdultCanoeing.Value Or AdultTennis.Value Or AdultWaterSkiing.Value Or AdultWindSurfing.Value > Form1.NumericUpDownAdults.Value And
          InfantCreche.Value > Form1.NumericUpDownInfants.Value Then
            Me.Hide()
            Form3.Visible = True
        End If



Is This A Good Question/Topic? 0
  • +

Replies To: if statement

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1046
  • View blog
  • Posts: 4,072
  • Joined: 02-July 08

Re: if statement

Posted 07 January 2011 - 10:02 AM

You can't concatenate value checks like that unless those are booleans. You also can use the OrElse boolean.

If AdultCanoeing.Value Or AdultTennis.Value

Should be

If AdultCanoeing.Value = something Or AdultTennis.Value = something ...
Was This Post Helpful? 0
  • +
  • -

#3 iansavell  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 14-December 10

Re: if statement

Posted 07 January 2011 - 11:34 AM

The BB code scrambles your layout a bit and all those OR'ed values confuse things but it looks as if the previous poster has one good point, you seem to be trying to do

IF (a or b or c) > 0 THEN


instead of the correct

IF a > 0 or b > 0 or c > 0 THEN


But also your core logic seems faulty - the no case shows Form3, the yes but nothing to select hides the current form without showing form3 and the yes but something left to select hides form3 then shows it without hiding the current form. Then you switch forms based on a completely different test involving number of people. This doesn't seem sensible to me.

Perhaps you should pseudo-code what you are aiming to achieve then write appropriate VB code.

IF no extras selected THEN
   ask if extras wanted
   IF extras wanted THEN
      stay on form
   ELSE
      move to next form
   END IF
ELSE
   move to next form
END IF


Is that about it?

Ian
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1