Vb question using select
Dim ans As Integer
Private Sub cmdcalc_Click()
ans = Val(txtage.Text)
Select Case ans
Case 0 - 16
lblcost1.Caption = "2"
Case 17 - 54
lblcost1.Caption = "3"
Case 55 - 80
lblcost1.Caption = "4"
Case 81 - 200
lblcost1.Caption = "5"
Case Else
lblcost1.Caption = "error"
lbltype2.Caption = "error"
MsgBox "Please correct the age"
End Select
lbltrace.Caption = Str$(ans)
End Sub
Private Sub cmdExit_Click()
End
End Sub
ive got this.
it doesnt seem to want to know the case statement. I think ive done it right. its just alittle college task. Ive used MSDN libabrys but hasnt shed any light cheers
Si
Private Sub cmdcalc_Click()
ans = Val(txtage.Text)
Select Case ans
Case 0 - 16
lblcost1.Caption = "2"
Case 17 - 54
lblcost1.Caption = "3"
Case 55 - 80
lblcost1.Caption = "4"
Case 81 - 200
lblcost1.Caption = "5"
Case Else
lblcost1.Caption = "error"
lbltype2.Caption = "error"
MsgBox "Please correct the age"
End Select
lbltrace.Caption = Str$(ans)
End Sub
Private Sub cmdExit_Click()
End
End Sub
ive got this.
it doesnt seem to want to know the case statement. I think ive done it right. its just alittle college task. Ive used MSDN libabrys but hasnt shed any light cheers
Si
The compiler is evaluating your different case conditions when it compiles. So for Case 0 - 16 it is calculating 0-16 = -16 and what it is actually testing for is Case -16. Enter a age of -16 in when you run the program and you'll see the code in the first case statement get run. Like wise it is doing similar for all the other Case statments. Any proper age you enter will just fall through to Case else. You could use something like 'Case 1,2,3,4,5,6' etc. What your trying to do isn't really suited to a Select Case statement, use if, if else, and else instead.
Cheers mate but it specifcally says use a select case statement.
Personally id use a list or combo rather then having to input an age!!
says in notes i can use
case
case 1-2
case 1,2,3,4
case "fred"
and thats out the book ive trace coded so know the right value is in age. So im stumpted!
Si
Personally id use a list or combo rather then having to input an age!!
says in notes i can use
case
case 1-2
case 1,2,3,4
case "fred"
and thats out the book ive trace coded so know the right value is in age. So im stumpted!
Si
sort of!
the overlaps are
0-16
17-54
55-81
82+
its ****ty little if x = b then Junior member rubbish
Private Sub cmdcalc_Click()
ans = Val(txtage.Text)
Select Case ans
Case Is < 16
lblcost1.Caption = "<16"
Case Is > 16 < 54
lblcost1.Caption = ">16 <54"
Case Is > 55 < 80
lblcost1.Caption = ">55 <80"
Case Is > 81
lblcost1.Caption = ">80"
End Select
lbltrace.Caption = Str$(ans)
End Sub
New code works for the 1st two. Fails on the 3rd and 4th case!
Si
[Edited by super_si - 9/26/2002 8:28:53 PM]
the overlaps are
0-16
17-54
55-81
82+
its ****ty little if x = b then Junior member rubbish
Private Sub cmdcalc_Click()
ans = Val(txtage.Text)
Select Case ans
Case Is < 16
lblcost1.Caption = "<16"
Case Is > 16 < 54
lblcost1.Caption = ">16 <54"
Case Is > 55 < 80
lblcost1.Caption = ">55 <80"
Case Is > 81
lblcost1.Caption = ">80"
End Select
lbltrace.Caption = Str$(ans)
End Sub
New code works for the 1st two. Fails on the 3rd and 4th case!
Si
[Edited by super_si - 9/26/2002 8:28:53 PM]
Trending Topics
>>pint to that guy
I am not a guy as I have mentioned before...
>>What did you search for?
At the top of my post I said I used the standard microsoft help in MS Access VBA...
Can you read help pages? Do you remember anything beyond your own nose?
I am not a guy as I have mentioned before...
>>What did you search for?
At the top of my post I said I used the standard microsoft help in MS Access VBA...
Can you read help pages? Do you remember anything beyond your own nose?
back hehehe.
ive got to do times tables 1 to user specifys!
For i = 1 To 10
lblanswer.Caption = "1"
Next i
prints 1 and thats it!
Anything to do with print Multiple lines to a label?
Thanks again.
Si
ive got to do times tables 1 to user specifys!
For i = 1 To 10
lblanswer.Caption = "1"
Next i
prints 1 and thats it!
Anything to do with print Multiple lines to a label?
Thanks again.
Si
This works for me in access
Private Sub Command1_Click()
Dim i As Integer
Label0.Caption = ""
For i = 1 To 10
Label0.Caption = Label0.Caption & Chr(13) & Chr(10) & i
Next i
End Sub
Chr(13) is a carriage return character
Chr(10) is a linefeed character
In combination they create a newline.
Does that help?
Private Sub Command1_Click()
Dim i As Integer
Label0.Caption = ""
For i = 1 To 10
Label0.Caption = Label0.Caption & Chr(13) & Chr(10) & i
Next i
End Sub
Chr(13) is a carriage return character
Chr(10) is a linefeed character
In combination they create a newline.
Does that help?
Honestly si, this isn't a dig, but your first point of call really should be the help system otherwise you're going to find yourself shafted sometime when you can't get on here, or people just give up 
The big secret of being a PC whizz is to know where to get the answers you need. It'll make you appear God-like.
Cheers,
Nick.

The big secret of being a PC whizz is to know where to get the answers you need. It'll make you appear God-like.
Cheers,
Nick.
GROUPS.GOOGLE.COM
WWW.VBFORUMS.COM
WWW.VBWEB.CO.UK
Just a couple Si - seriously m8 you will find your answers quicker by searching sites like these than you will by asking here. (no offence ppl)
BTW lblname.Caption = lblname.caption & "TEXTHERE" & VbCrLf & "TEXT2" & vbcrlf & "TEXT3"
WWW.VBFORUMS.COM
WWW.VBWEB.CO.UK
Just a couple Si - seriously m8 you will find your answers quicker by searching sites like these than you will by asking here. (no offence ppl)
BTW lblname.Caption = lblname.caption & "TEXTHERE" & VbCrLf & "TEXT2" & vbcrlf & "TEXT3"
Thread
Thread Starter
Forum
Replies
Last Post





