Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / December 2004



Tip: Looking for answers? Try searching our database.

how to use multiple statements

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JoeF - 29 Dec 2004 20:07 GMT
Hi,

How do I state multiple conditions in an If Then End If statement.  For e.g.
Me.From_File.Value = 0
        Me.To_File.Value = 7999
I want to also include values 9000 to 15000.  If I use AND to combine the
statements I get an error.

Thanks for any input.
Joe
Bob O`Bob - 29 Dec 2004 21:38 GMT
> Hi,
>
[quoted text clipped - 6 lines]
> Thanks for any input.
> Joe

one way:

  If (x >= 0 And x <= 7999) Or (x >= 9000 And x <= 15000) Then
      'code here
  End If

Another option:

  Select Case x
  Case 0 To 7999, 9000 To 15000
      'code here
  End Select

    Bob
JoeF - 30 Dec 2004 17:33 GMT
Thanks, Bob. I tried that, but no luck.  
Here's what I'm struggling with:

   If Option1 Then
       Me.From_File.Value = 8000
       Me.To_File.Value = 9000
   ElseIf Option2 Then
       Me.From_File.Value = 0
       Me.To_File.Value = 7999
   ElseIf Option3 Then
       Me.From_File.Value = 0
       Me.To_File.Value = 9000
   End If

In option 2 I want to also include values 9001 to 15000.

Joe

> > Hi,
> >
[quoted text clipped - 21 lines]
>
>     Bob
MikeD - 31 Dec 2004 04:08 GMT
> Thanks, Bob. I tried that, but no luck.
> Here's what I'm struggling with:
[quoted text clipped - 11 lines]
>
> In option 2 I want to also include values 9001 to 15000.

Let me make sure I understand.  You want both 0 and 9001 assigned to
Me.From_File.Value and both 7999 and 15000 assigned to Me.To_File.Value?

You can't.  Only one value at a time can be assigned to each of the Value
properties. One thing you could do is assign values as follows:

Me.From_File.Value = 0
Me.To_File.Value = 15000

and then include a condition to skip values 8000 to 9000 (assuming there's a
loop somewhere).  Or, you might perform the action(s) for the first range of
values and then repeat those actions for the second range of values.

Another possibility would be to add a 4th option button that is only enabled
if Option2 is enabled (thusly allowing the user to select either range for
Option2).

Knowing exactly what these values represent and how you're using them might
help us formulate better alternatives for you. It's pretty obvious they are
for sets of files, but it's unclear how what they actually represent
(probably part of the file names, but that's conjecture).  It's not even
clear if you're even looping through the ranges of values. The more
information we have, the better we can help. It's always better to just
provide as much information as possible up front than for us to have to
query for it. That just takes more time for us to be able to help you.

BTW, you should not rely on default property values. It's a bad habit to get
into and eventually will lead to trouble (particularly if you ever change to
VB.NET).  Besides that, it just makes your code less readable and concise.
IOW, you should use Option1.Value, Option2.Value, Option3.Value.

Mike
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.