|
-
Jan 22nd, 2003, 05:24 PM
#1
Thread Starter
Lively Member
If Then...help[resolved]
Ok, I want to add 12 to all numbers from 1 To 11 that added to the combobox.
I can only do it one at a time like this....
VB Code:
If cboHours2.Text = 5 Then
Dim intNumber As Integer
MsgBox Val(cboHours2.Text) + 12
End If
There has to be a way to do it with one If..Then Statement.
please help
Last edited by notSOMLS1; Jan 22nd, 2003 at 06:19 PM.
-
Jan 22nd, 2003, 05:27 PM
#2
Member
hi
you could try this:
If cboHours2.Text <12 Then
Dim intNumber As Integer
MsgBox Val(cboHours2.Text) + 12
End If
i assume I am missing something though seems to easy
tal mcmahon
-
Jan 22nd, 2003, 05:28 PM
#3
Frenzied Member
Can you rephrase the question? It's hard to understand what you are trying to do. Assume we know nothing about your project...
-
Jan 22nd, 2003, 06:06 PM
#4
Thread Starter
Lively Member
Originally posted by seaweed
Can you rephrase the question? It's hard to understand what you are trying to do. Assume we know nothing about your project...
heh, ok
Lets say the user can enter in any number between 1 and 20.
12 will be added to any number between 1 and 11. The numbers from 12 to 20 will have nothing added.
So for example the user enters "7", the output will be 19.
Or if 10 is entered, the output will be 22
It seems like I should be able to write something like this....
VB Code:
If txtNumber.Text is 1 To 11 Then
lblOutput.Caption = txtNumber.Text + 12
End If
But that code isn't right... So is there a way to do it without using < or > ??
-
Jan 22nd, 2003, 06:14 PM
#5
Frenzied Member
VB Code:
If txtNumber.Text is < 12 Then
lblOutput.Caption = txtNumber.Text + 12
End If
-
Jan 22nd, 2003, 06:16 PM
#6
Frenzied Member
Oh...didn't see your restriction on "<". Try this instead:
VB Code:
If txtNumber.Text \ 12 = 0 Then
lblOutput.Caption = txtNumber.Text + 12
End If
-
Jan 22nd, 2003, 11:02 PM
#7
Fanatic Member
VB Code:
If txtNumber.Text \ 12 = 0 Then
lblOutput.Caption = txtNumber.Text + 12
End If
Would the above work as he wanted it to? It looks to me that
this code would only add 12 if txtNumber \ 12 = 0 and he wants
all numbers 1 through 11 right?
If I am wrong so be it, but I can't think of a way to do it without the > operator. I bet there is a more detailed way but can't think of it without having to use a ton of Or's and And's on that statement.
-
Jan 22nd, 2003, 11:26 PM
#8
Frenzied Member
Uhhh...
It looks to me that this code would only add 12 if txtNumber \ 12 = 0 and he wants all numbers 1 through 11 right?
You're right, it only adds 12 if number \ 12 = 0.
This includes all numbers from 1 to 11. So, yes, it works just fine the way he wants it to! (Notice that it is not a normal division /, but integer division \).
-
Jan 23rd, 2003, 12:31 PM
#9
Fanatic Member
Didnt notice the "/" was on here from linux last night before bed and the Linux mozilla browser makes my eyes hurt. Sry =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|