|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Problem with case statement
I am currently working on an export of transactions and I can't seem to get this little piece of my code to work. Option1, Option2, etc. are option buttons
If fld.Name = "sequence_number" Then Select Case options Case Option1 = True Print #filenum, "ZP"; Case Option2 = True Print #filenum, "XP"; Case Option3 = True Print #filenum, "YP"; Case Option4 = True Print #filenum, "YC"; Case Option5 = True Print #filenum, "XC"; Case Option6 = True Print #filenum, "ZC"; End Select When I select option1 I get ZP to print within my output on all the others it doesn't work. I also get ZP printing for Option6. It doesn't make any sense to me! Thanks guys. I'd appreciate any help. |
|
#2
|
||||
|
||||
|
I don't quite think the select case works the way you think it does, but I may be wrong.
I believe you would be better off checking the value of each individual option button value with a if then block. The select case block will only evaluate one expression. |
|
#3
|
|||
|
|||
|
ok,
i was originally going to do that, but then was told that a case statement would work. I kind of had the same feeling you do about that. However, I tried an if then statement within the if statement i have in my previous post. It didn't seem to get recognized at all. I also did not get any code errors. |
|
#4
|
||||
|
||||
|
step through it with the debugger and see what is going on.
|
|
#5
|
|||
|
|||
|
what is options? this select case is also valid:
Code:
If fld.Name = "sequence_number" Then
Select Case True
Case Option1.Value
Print #filenum, "ZP";
Case Option2.Value
Print #filenum, "XP";
Case Option3.Value
Print #filenum, "YP";
Case Option4.Value
Print #filenum, "YC";
Case Option5.Value
Print #filenum, "XC";
Case Option6.Value
Print #filenum, "ZC";
End Select
End If
__________________
Programmer's Corner |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Problem with case statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|