Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Select Case For Games


when i go to use the select case in visual basic.net i type

select case keycode
case vbkeyleft


but it always says i need to declare keycode and vbkeyleft *** in visual basic 6.0 it never did that




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Can A Case In A Select Case Statement Call Other Statements?
I have a Select Case statement where each case has 10 - 20 lines of code. If the user selects the "master" option, I would like that case to call all of the other cases. That way, I don't have to retype all the code.

For example, if you had a text box with a command button, the kind of case I'm looking for would look like:

Private Sub Command1_Click()Select Case Text1Case "A"Call cases "B" and "C"Case "B"MsgBox "B"Case "C"MsgBox "C"End SelectEnd Sub

So if the user typed "A" and clicked, there would be a "B" messagebox and a "C" messagebox.

Does anyone know if this can be done?

Thank you,

Steve Geller

How To Make VB's Select/case Mimic C's Switch/case
in C, I can do this

number=1;
switch(number)
{

case 1:
case 2:
case 3:
printf("
Case 1-2-3");
break;

default:
break

}


in VB when I try to do this

number = 1

select case number

case 1
case 2
case 3

case else
'none of the above

end select

the case else path is taken.

It appears that the case in C are or'd but in vb they are not

I also tried this

number = 1

select case number

case 1 or 2 or 3

case else
'none of the above

end select

but the else path was taken again.

Is there something I'm missing, or can't this be done in vb ?
I don't want to check for a range of values, just a few discrete values.

End Select Without Select Case, But Select Case Exists...
Code:
Private Sub RecordControls_Click
Select Case Index
Case 0
On Error GoTo ErrorHandler
If MasterControl.Text = "" Then
MsgBox "You must specify a header in which to put the data.", vbInformation, App.Title
Exit Sub
End If
For i = 0 To Data.Count - 1
If Data(i).Text = "" Or DataType.Text = "" Then
MsgBox "One or more of the required fields have not been filled in.", vbInformation, "Cannot continue"
Exit Sub
End If
Next i
RecordSource = "SELECT * FROM " & MasterControl.Text & " ORDER BY Name"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "Databases" & MasterControl.Text & ".mdb;Persist Security Info=False"
rs.Open RecordSource, ConnectionString, adOpenKeyset, adLockOptimistic
For i = 1 To rs.RecordCount
If rs.BOF = False Then
rs.MoveFirst
End If
If rs.EOF = True Then Exit For
If Data(0).Text = rs!Name Then
MsgBox "Duplicate items not allowed", vbCritical, "Can't create record"
Exit Sub
Else
rs.MoveNext
End If
rs.AddNew
rs!Name = Data(0).Text
rs!DataType = DataType.Text
rs!Data = Data(1).Text
rs.Update
rs.Close
Set WkSpc = Nothing
Set rs = Nothing
OrganizerDatabase.ListItems.Add , , Data(0).Text
End Select
End Sub


As you can see, Select Case is the very first line in my code, yet it gives me the aforementioned error. Why is this?

Also, I need to know how to catch cancel button clicks when creating a new datalink dynamically.

This code opens a box that creates a new dynamic datalink to the database you choose. It's just like right-clicking a udl file and selecting properties.


Code:
Set conn = dl.PromptNew


I want to know how to catch cancel button clicks from this box.

Temporarily Removing A Case From Case Select
hey, just wondering if it could be done.

i'm making a black-jack game for school, and i need a way to keep used cards from being chosen twice, and i'm using a case-select to do it. i've tried a few different things, such as a Do While loop, and various others.

i was also thinking i could make an array and dump all the used cards into it, and the compare them when the "Hit" button is pressed, but i'm not sure about the syntax and the coding for it.

i was also wondering if you guys knew of a better way to select the cards. writing a case select with 52 cases everytime looks terrible ...

so yeah, any suggestions?

Case Without Select Case? + Use A Variable As A Function?
I am making a maths quiz in VB6 for a school project, and i'm in a bit of a rut. Basically, i'm trying to write the code for when a user answers a question. The function (Addition, Subtraction, Multiplication, Division etc) is defined using randomly generated numbers (eg, 1 = "+").

So basically i've tried to say "if answer is equal to the equation, then do this, or do this"

I have the function setup like this (where label3.caption is the math function)



Code:
If Label3.Caption = 0 Then
Label3.Caption = "+"
ElseIf Label3.Caption = 1 Then
Label3.Caption = "-"
ElseIf Label3.Caption = 2 Then
Label3.Caption = "*"
ElseIf Label3.Caption = 3 Then
Label3.Caption = "/"
End If


I originally wanted to simply do something like "if firstnumber (label3.caption) secondnumber, then etc"

I couldn't figure out a way to do this, so i decided i would try a case select.
No matter what i do i get the error "Case Without Case Select"



Code:
Private Sub Command1_Click()
' if user's answer in the text box is correct or not show msg box, do array to store
' the score, etc

functioncase = Label3.Caption + 1

Select Case functioncase


Case 1
If Text1.Text = Label1.Caption + Label2.Caption Then
MsgBox "CORRECT"
Else
MsgBox "INCORRECT"


Case 2
If Text1.Text = Label1.Caption - Label2.Caption Then
MsgBox "CORRECT"
Else
MsgBox "INCORRECT"


Case 3
If Text1.Text = Label1.Caption * Label2.Caption Then
MsgBox "CORRECT"
Else
MsgBox "INCORRECT"


Case 4
If Text1.Text = Label1.Caption / Label2.Caption Then
MsgBox "CORRECT"
Else
MsgBox "INCORRECT"


Case Else
MsgBox "WFTF"
End Select

End Sub




I have no idea how to get this working!
Please share your knowledge with me.

Select Case Default *RESOLVED: Case Else*
Is there a default case? In C++ you simply insert a "Default:" into the select and it handles all other cases that you don't look for. Simply, a default case would be the 'else' of a select case statement. Something like this ....


VB Code:
yellow = "no" Select Case yellow     Case "yes": MsgBox "It is yellow."     Default : Msgbox "It is not yellow."End Select

... thanks.

Case Without Select Case Error For No Reason
Hi,

This is very nonsense. That error keeps popping up at run time for absolutely no reason as far as i'm concern because i can't think of ANY reason why it wouldn't work. IT is a simple tic-tac-toe game ( not finished yet ) and i hope you people can have a look at the source ( very short ) and solve that select case error.

many thnx

Case Select In Report, Select Expert Formula For Crystal Reports RDC
I am using Crystal 8 RDC in my VB app. I run a number of reports with paramaters which run beautifully. Typicall when I Enter a Selection formula in the Select Expert it will look something like:

{ado.Issuer} Is like {?IssuerParm}

Can anyone give me an example of how to use an If statement or a Case Select in the Select Expert of Crystal Reports RDC?

Select Case Structure Question How To Select Two Conditionsat A Time?
hi
i am using combobox and listbox. I want to use select case structure
using both combo1 and list1.I know that it can be handled easyly by
using nested if sutructure,but want to know what say select case structure
im using this but it not works for both at a time. tell me is it possible
to use ?? if yes then plz tell me what the code is because
i don't know about the select case structure very much.
THANKS


VB Code:
Private Sub Form_Load() Combo1.Clear    Combo1.AddItem "one"        Combo1.AddItem "two"            Combo1.AddItem "three"                Combo1.AddItem "four"    List1.Clear        List1.AddItem "1"            List1.AddItem "2"                List1.AddItem "3"                    List1.AddItem "4"  End Sub   Private Sub Command1_Click()   Select Case (Combo1.ListIndex And List1.ListIndex)     Case 0 And 0        MsgBox "one 1"             Case 0 And 1                    MsgBox "one 2 "                            Case 0 And 2                                MsgBox "one 3 "            End Select End Sub

Skipping A CASE In Select Case...
Not sure exactly the best way to ask this, so I'll try bluntly.

I have a select case WITHIN a select case.

For the 1st case, I have 3 options
For the 2nd case, I have 4 options

such as...


Code:
Select Case FillMethod
Case 0 'Normal Fill Style
Select Case FillStyle
Case 0
Case 1
Case 2
Case 3
End Select
Case 1 'Center Out.
...
...
End Select
End Select
Lets say, FillMethod evaluates to 0
In that case, 0 and 1 (Of FillStyle) are both going to do the same thing, but i can not remove one in favor of the other, because it is used elsewhere in code.

Is there a way to do this? If FillStyle evaluates to Case 0, or Case 1, run the code ONCE, or replace the 2 Case statements with something like Case 0 OR 1 ?

Case Select Adding A New Case
is it possible to add a case to a select case object from within the code.

example:
i have a ascii file with customer adresses but every now and then there is an updated file with new customers, now i wont to import this file and a case for every adress, but this has to go automatic..so the code has to generate more cases and combobox1.additem

the code:

Code:
Private Sub UserForm_Initialize()

ComboBox1.AddItem "adress 1" 'ListIndex = 0
ComboBox1.AddItem "adress 2" 'ListIndex = 1
ComboBox1.AddItem "adress 3" 'ListIndex = 2
ComboBox1.AddItem "adress 4" 'ListIndex = 3
ComboBox1.AddItem "adress 5" 'ListIndex = 4
ComboBox1.AddItem "adress 6" 'ListIndex = 5

ComboBox1.Style = fmStyleDropDownList
ComboBox1.BoundColumn = 0
ComboBox1.ListIndex = 0

End Sub


Private Sub ComboBox1_Click()
Select Case ComboBox1.Value
Case 0
Label2.Caption = "adress 1"
Label3.Caption = "street 1"

Case 1
Label2.Caption = "adress 2"
Label3.Caption = "street 2"

Case 2
Label2.Caption = "adress 3"
Label3.Caption = "street 3"

Case 3
Label2.Caption = "adress 4"
Label3.Caption = "street 4"

Case 4
Label2.Caption = "adress 5"
Label3.Caption = "street 5"

Case 5
Label2.Caption = "adress 6"
Label3.Caption = "street 6"

End Select

End Sub

thx for any help.

regards,
Marco

I Get "Case Without Select Case", But There IS A Select Case!
VB Code:
For i = 0 To UBound(Script)  sLine = Split(Script(i), " ")  Select Case UCase(sLine(0))   Case "BACKGROUND"    Me.BackColor = sLine(1)       Case "GO"    i = sLine(1)   Case "LINE"    'Unload cLine(Line(1))    'Load cLine(Line(1))    If UCase(sLine(1)) = "NEW" Then    sLine(1) = cLine.Count + 1         cLine(sLine(1)).X1 = sLine(2)    cLine(sLine(1)).Y1 = sLine(3)    cLine(sLine(1)).X2 = sLine(4)    cLine(sLine(1)).Y2 = sLine(5)    cLine(sLine(1)).BorderColor = sLine(6)    cLine(sLine(1)).Visible = True   [b]Case "SLEEP"[/b]    Sleep sLine(1)   Case "'"     GoTo 2   Case Else    If MsgBox("""" & Script(i) & """" & vbNewLine & "this is an invalid sline of code. End Script?", vbYesNo) = vbYes Then Exit Sub  End Select  DoEvents2 Next
The bold line is where i get this error...apparently VB is buggy.

Case Without Select Case?
Dim veryeasy as string


Randomize
veryeasy = (Int(Rnd * 25) + 1)
Select Case veryeasy
Case 1
blah blah
blah
blah

Case 2
blah blah
blah

Case 3
blah
blah

etc...




The game reads Case 1 fine but then I get an error on 'case 2' saying that I'm using case without select case but I have select case right at the top. I shouldn't have to put 'select case veryeasy' for each case. I've never done it this way and I've never gotten an error. Why now? What could I have possibly done?

Case Without Select Case
when the following code is executed it gives me an error saying "Case without case select". I'm looking at the case select statement



Code:
Private Sub tabConversion_Click(PreviousTab As Integer)
'select the table to load into the listboxes by using the tab property of the
'tabs to find the required table
Dim intTab As Integer
Dim strFromCheck As String
Dim intCounter As Integer
intTab = tabConversion.Tab
Select Case intTab
Case Is = 0
'tells where to get the records from
adoConversion.Refresh
adoConversion.RecordSource = "SELECT * FROM tblAcceleration"
lstAccelerationFrom.Clear 'clear the FROM list box
lstAccelerationTo.Clear 'clear the TO list box
'read the record set while it isn't the end of the record set
Do While Not adoConversion.Recordset.EOF
'set the string equal to the record
strNewFrom = adoConversion.Recordset("fldFrom")
strNewTo = adoConversion.Recordset("fldToType")
'test to see if the string has already been added to the list box
If strOldFrom <> strNewFrom Then
' Add item to the FROM list box
lstAccelerationFrom.AddItem adoConversion.Recordset("fldFrom")
End If
If strOldTo <> strNewTo Then
'Add item to the TO list box
lstAccelerationTo.AddItem adoConversion.Recordset("fldToType")
End If
'The old is really old the next time around
strOldFrom = strNewFrom
strOldTo = strNewTo
'move to the next record set
adoConversion.Recordset.MoveNext
Case Is = 1
'tells where to get the records from
adoConversion.Refresh
adoConversion.RecordSource = "SELECT * FROM tblAngle"
lstAngleFrom.Clear 'clear the FROM list box
lstAngleTo.Clear 'clear the TO list box
'read the record set while it isn't the end of the record set
Do While Not adoConversion.Recordset.EOF
'set the string equal to the record
strNewFrom = adoConversion.Recordset("fldFrom")
strNewTo = adoConversion.Recordset("fldToType")
'test to see if the string has already been added to the list box
If strOldFrom <> strNewFrom Then
' Add item to the FROM list box
lstAngleFrom.AddItem adoConversion.Recordset("fldFrom")
End If
If strOldTo <> strNewTo Then
'Add item to the TO list box
lstAngleTo.AddItem adoConversion.Recordset("fldToType")
End If
'The old is really old the next time around
strOldFrom = strNewFrom
strOldTo = strNewTo
'move to the next record set
adoConversion.Recordset.MoveNext
next case etc...

Case Without Select Case
i cant spot the error in this code, but it happens everytime i press the command button. can anyone spot it.....


Code:
Private Sub cmdExtraFunction_Click(Index As Integer)

lngPo2 = Val(lblDisplay.Caption)

Select Case Index


Case 0 'case positve to negative
lblDisplay.Caption = -Val(lblDisplay.Caption)

Case 1 'case 1/x
If Val(lblDisplay.Caption) <> 0 Then
lblDisplay.Caption = 1 / Val(lblDisplay.Caption)

Case 2 'case percentage
lblDisplay.Caption = firstnum * Val("." & lblDisplay.Caption)

Case 3 'case squareroot
If Val(lblDisplay.Caption) = 0 Then
lblDisplay.Caption = "Error"
Exit Sub
Else
lblDisplay.Caption = Sqr(Val(lblDisplay.Caption))
End If

Case 4 'case power 2
If Abs(Val(lblDisplay.Caption)) < 46300 Or Abs(Val(lblDisplay.Caption)) > -46300 Then
lblDisplay.Caption = Str((lngPo2 * lngPo2))
ElseIf Abs(Val(lblDisplay.Caption)) > 46300 Or Abs(Val(lblDisplay.Caption)) < -46300 Then
MsgBox ("The Number Is Too Large or Too Small")
End If

End Select

End Sub
thanks in advance.. been bugging me for 10 minutes now (rolls eyes knowing its probably something trivial)

Case Without Select Case
Hello All,


VB Code:
For Ctr = 0 To catDava.Tables.Count - 1        pbrProgress.Min = 0        Select Case LCase(catDava.Tables(Ctr).Name)            Case "account_group_mst"                index = 0                If Not check_primary(catDava.Tables(Ctr), "", "PK_AGM", "account_group_id", "", index) Then                    If index >= 0 Then                        With rsprimary                            If .State = adStateOpen Then .Close                                .Open "SELECT FIRST(account_group_id),COUNT(account_group_id) FROM Account_group_mst GROUP BY account_group_id HAVING COUNT(account_group_id) > 1", de.Connection1, adOpenDynamic, adLockOptimistic, adCmdText                                pbrProgress.value = pbrProgress.Min                                If .RecordCount > 0 Then pbrProgress.Max = .RecordCount                                    Do While Not .EOF                                        .Delete                                        pbrProgress.value = pbrProgress.value + 1                                        .MoveNext                                    Loop                        End With                        de.Connection1.Execute "ALTER TABLE Account_group_mst ADD CONSTRAINT PK_AGM PRIMARY KEY (account_group_id)"                    End If                End IfCase "bank_mst"                index = 0                If Not check_primary(catDava.Tables(Ctr), "", "PK_BM", "Bank_id", "", index) Then                    If index >= 0 Then                        With rsprimary                            If .State = adStateOpen Then .Close                                .Open "SELECT FIRST(Bank_id),COUNT(Bank_id) FROM Bank_mst GROUP BY Bank_id HAVING COUNT(Bank_id) > 1", de.Connection1, adOpenDynamic, adLockOptimistic, adCmdText                                pbrProgress.value = pbrProgress.Min                                If .RecordCount > 0 Then pbrProgress.Max = .RecordCount                                    Do While Not .EOF                                        .Delete                                        pbrProgress.value = pbrProgress.value + 1                                        .MoveNext                                    Loop                        End With                        de.Connection1.Execute "ALTER TABLE Bank_mst ADD CONSTRAINT PK_BM PRIMARY KEY (Bank_id)"                    End If                End If End Select    Next

I dont know why this is not working? its giving compile error "case without select case"....waiting 4 +ve reply

Select Case Statement(Case "xxx")
eg.
message = InputBox$("What u want to turn on", "Testing")
Select Case message
Case "light on": MsgBox "Light turns on"
Case "light off": MsgBox "Light turns off"
Case "fan on": MsgBox "fan turns on"
Case "fan off": MsgBox "fan turns off"
Case Else: MsgBox "no orders"
End Select

Qns: Is there any commands that I can use,in the case"xxx", to irregardless of the capital or small letters. So If i input "FaN On", MsgBox " fan turns on" will appears

understand...???
Help!!!

Select Case Help
I'm trying to create a Blackjack game but I'm having trouble with my select case code, here's a portion of it -


Code:
playerscore(1) = 0
playerscore(2) = 0
For x = 1 To playercount
Select Case playerscard(playercount)
Case Is = "Heart1" Or "Diamond1" Or "Club1" Or "Spade1"
playerscore(1) = playerscore(1) + 1
playerscore(2) = playerscore(2) + 11
Case Is = "Heart2" Or "Diamond2" Or "Club2" Or "Spade2"
playerscore(1) = playerscore(1) + 2
playerscore(2) = playerscore(2) + 2
That code is used to calculate the players score, there are two score in case the user has an ace. (there is also more cases for the select case)

My problem is that when I run the code I get a type mismatch error on this line -


Code:
Case Is = "Heart1" Or "Diamond1" Or "Club1" Or "Spade1"
I have the playerscard(playercount) variable declared as a string. Does anyone know how to fix this error? Also, if anyone has a better idea about calculating the score instead of select case, I'd like to hear it. :P

Select Case Using And
Hello, I am working with VBA in Excel

I am having a select case problem with the And operator, my code goes as such:


Code:
.
.
.
Select Case FinishInch

Case Is <= 0.00033
FinishInt = 60
Case Is > 0.00033 And FinishInch <= 0.00037
FinishInt = 59
Case Is > 0.00037 And FinishInch <= 0.000415
FinishInt = 58
.
.
.
End Select

The problem is if for instance FinishInch is = .000410 it should give a value for FinishInt as 58. however it doesnt seem to be getting past the first AND operator.
No matter what the value of FinishInch is, as long as it is > .00033 FinishInt gets a value of 59.

I have tried defining FinishInch as double, single and variant with no success.

What am I doing wrong???

Thanks
Place

Using Select Case With Or
I have the following example:

Sub myexample()
Dim myVar As String

myVar = "one"

Select Case myVar
'this is where the error occurs
Case "One" Or "Two"
MsgBox "ok1"
Case "Three"
MsgBox "ok2"
End Select

End Sub

I get a type mismatch error where the case is "one" or "two". Does anyone know how to make the select case work for different possabilites.

Select Case
Hey I am having trouble using the Select Case code in vb. I am trying to use it for a progress bar. I have the program designed to initiate Timer1 whenever cmdInstall is clicked. I am trying to place the Select Case in the timer sub in conjunction with a progress bar. every case i want the progress bar to increase by so many increments, and I want so much code to be completed as well.. any help? Thanks!

Select Case Help
I'm trying to do the following in VB, but it doesn't work, if x is set to "1" or to "2", The Case Else: still triggers.
Here's the code:

Code:
Sub Main()
Dim x As String

x = "1"

Select Case x
Case "1" Or "2":
MsgBox "1 or 2"

Case Else:
MsgBox "else"

End Select

End Sub
If I change the Case "1" Or "2" to Case ".vbs" Or ".js" I get an type missmatch error on that line. I'm sure it's becuase of Or operating as adding those two together or something, but I can't find any solution for it.

How should I do this?

Select Case Help..?
Im making a grading program for my Intro to Pro VB class with VB6 im missing something in this code and I can't figure it out.. please help me asap..

Code:
Private Sub cmdCalculate_Click()
sngTest1 = Val(txtTest1.Text)
sngTest2 = Val(txtTest2.Text)
sngTest3 = Val(txtTest3.Text)
If ValidGrade(txtTest1.Text) And ValidGrade(txtTest2.Text) And ValidGrade(txtTest3.Text) Then
mintAverage = (sngTest1 + sngTest2 + sngTest3) / 3
End If
txtGrade.Text = mstrGrade
Select Case mintAverage
Case "0" To "58"
mstrGrade = "F"
Case "59" To "68"
mstrGrade = "D"
Case "69" To "78"
mstrGrade = "C"
Case "79" To "89"
mstrGrade = "B"
Case "90" To "100"
mstrGrade = "A"
End Select
End Sub
*ValidGrade is a private funcation for validating the numbers input into txtTest1.text thru txtTest3.text is between 0 and 100*
If all code is needed let me know and ill post it all... it isnt that long..
when I click Calculate when testing it it takes the mstrGrade for the first ="X" no matter what it is, i want it to take the average of the 3 txtTests then use that to determine the grade, so that using the select case depending on what its between it defines txtGrade.text as the letter grade associated with that specific case.
THanks for any help... I need this done by tuesday plus another project.

Select Case Help
1. It asks me for the date of the holiday
2. I enter which day, ie, Monday, Tuesday, etc
3. It should go to the proper Case and then perform that action.

It does't do it, so could anybody take a look and see what I am doing wrong.



Code:
Response = MsgBox(HolidayMessage, HolidayStyle, HolidayTitle)
If Response = vbYes Then
HolidayDate = InputBox(InpHolidayMsg, InpHolidatyTitle, InpHolidayDef)
Else: End
End If

Select Case HolidayDate
Case Monday
Range("C6:C14").Value = "Holiday"

'Range("C16:C28").Value = "Holiday"


Case Tuesday
Range("D6:D14").Value = "Holiday"


Case Wednesday
Range("E6:E14").Value = "Holiday"

Case Thursday
Range("F6:F14").Value = "Holiday"

Case Friday
Range("G6:G14").Value = "Holiday"

Case Saturday
Range("H6:H14").Value = "Holiday"

Case Sunday
Range("I6:I14").Value = "Holiday"
End Select
'End If
End Sub

Select Case Help????
ok i have a form with 14 option buttons on them named optMod(0), optMod(1), optMod(2), etc....

right now i am using if then statements

If optMod(0).Value = True Then
MsgBox ("0")
ElseIf optMod(1).Value = True Then
MsgBox ("1")
ElseIf optMod(2).Value = True Then
MsgBox ("2")
.
.
.
.
End If

what is the correct syntax to re-write this using a case statement... i have used them, but never with option buttons.

Select Case Vs. If...then
if i am testing a condition like the following, is it better to use a case statement or a bunch of if then statements.

i have a grid that i am looping through... i check to see if the text is red, yellow, green, blue, orange, or purple... once it checks the text it changes the field to a different word

'red' becomes 'obsolete'
'yellow' becomes 'sole source'
etc....

so should i use a case or if statement and why?

If...Then...Else Or Select Case?
I have a form with many command buttons. Depending on which comdbutton is clicked, a [pre-saved] document will open. It may be a document, spreadsheet, .pdf file, database or whatever. I'm pretty sure I can do it as an If...Then...Else statement but would a Select Case statement be more efficient?. I had it running with each button having it's own click event but it won't compile - 'out of memory error'. If the Select Case Statement is the better option, can someone give me an example to kick it off please? I am using VB5 and VB6. Also, how the hell do I get an .avi or .swf file to run as a click event?

Thanks heaps
Jim

Need Help With Select Case...
Well, I thought everything was going alright until I noticed my tickers/counters weren't updating correctly. Here's my code:

Code:
tcount = 8

Select Case Len(tcount)
Case "1"
frmBis.imgT4.Picture = LoadPicture(App.Path & "Images" & tcount & ".bmp")

Case "2"
intDigit1 = Left$(tcount, 1)
frmBis.imgT3.Picture = LoadPicture(App.Path & "Images" & intDigit1 & ".bmp")
frmBis.imgT4.Picture = LoadPicture(App.Path & "Images" & Right$(tcount, 1) & ".bmp")

Case "3"
intDigit2 = Left$(tcount, 1)
intDigit1 = Left$(tcount, 2)
intDigit1 = Right$(intDigit1, 1)
frmBis.imgT2.Picture = LoadPicture(App.Path & "Images" & intDigit2 & ".bmp")
frmBis.imgT3.Picture = LoadPicture(App.Path & "Images" & intDigit1 & ".bmp")
frmBis.imgT4.Picture = LoadPicture(App.Path & "Images" & Right$(tcount, 1) & ".bmp")
End Select

Now, the "tcount = 8" is NOT part of the code. It will always start out as "0" and then the code will do "tcount = tcount + 1". I just have it in there so that I can test high numbers without having to step through the code in order to increase the count.
Anyway, no matter what value I make tcount, the "Len(tcount)" will always return a 2. All the variables included (tcount, intDigit, etc) are stored as integers. My "ticker/counter" will allow up to 9999, though more than 99% of the time, numbers will not go above 250.
Does anyone know why this is not working? I could probably just set a new variable to store the length of tcount before I enter the Select Case, right? It would be something like this:

Code:
tcount = 8665

NewVar = Len(tcount)

Select Case NewVar
Case "1"
frmBis.imgT4.Picture = LoadPicture(App.Path & "Images" & tcount & ".bmp")

Case "2"
intDigit1 = Left$(tcount, 1)
frmBis.imgT3.Picture = LoadPicture(App.Path & "Images" & intDigit1 & ".bmp")
frmBis.imgT4.Picture = LoadPicture(App.Path & "Images" & Right$(tcount, 1) & ".bmp")

Case "3"
intDigit2 = Left$(tcount, 1)
intDigit1 = Left$(tcount, 2)
intDigit1 = Right$(intDigit1, 1)
frmBis.imgT2.Picture = LoadPicture(App.Path & "Images" & intDigit2 & ".bmp")
frmBis.imgT3.Picture = LoadPicture(App.Path & "Images" & intDigit1 & ".bmp")
frmBis.imgT4.Picture = LoadPicture(App.Path & "Images" & Right$(tcount, 1) & ".bmp")
End Select
Would this be better to do or does it really matter? If you need any more info, please let me know.

Thanks!

Select Case
can anyone give me an example of how a select case works?

Select Case?
how can i do this?

select case x
case is <90 and is>3
do something
case is>0 and is <4
do something else
end select

i need to know how to use the IS and AND in a case statement to test if something is in a certain range

Using OR In A Select Case
Just wondering if one can use OR in a case?


Code:
Select Case p_RawRecord(p_FieldNumber)
Case "IV" Or "IVORY"
p_FinalRecord(14) = "IVORY"

Case "BK" Or "BLACK" Or "BLK"
p_FinalRecord(14) = "BLACK"

Case "WH" Or "WHITE"
p_FinalRecord(14) = "WHITE"

Case "GY" Or "GRAY"
p_FinalRecord(14) = "GRAY"

Case "LT GY" Or "LTGY" Or "LT GRAY" Or "LIGHT GRAY"
p_FinalRecord(14) = "LT GRAY"

Case "BR" Or "BROWN"
p_FinalRecord(14) = "BROWN"

End Select

Otherwise i can just do individule cases for each case.

Thanks

Select Case
I need to make a tic tac toe game and use the DragDrop Event, and DragIcon and DragMode properties to make it work.

I am stuck on how to write code to check for a winning tic tac toe combinaiton.

I know that there are 8 combinations of indexes of the imgBoard control where all three images are the same and result in a winner of that current source control (being the last image dragged and dropped onto the board)

indexes that are winners:
0, 3, 6
1, 4, 7
2, 5, 8
0, 1, 2
3, 4, 5
6, 7, 8
0, 4, 8
2, 4, 6

I tried a series of if...else...then loops to check if the source.picture matched the image control in the imgBoard array, but I am getting an error with my if...else....then loop.

Please point me in the right direction.

Select Case
Can anyone see why I am able to calculate correctly using this select statment? If I enter a number < 199, it doesnt calculate until it hits 0.6. If I enter 199, it will calculate at 0.5 like it should.
Most of the number I enter will not calculate correctly, most will calculate on the 0.6.
Have any ideas, see any problem with my statement?

Private Sub cmdCalc_Click()
'CHECK VALUE OF TEXT BOX COUNT TO DETERMINE RATE
If IsNumeric(txtCount) Then
Select Case txtCount
Case 1 To 199
msngEarned = Val(txtCount) * 0.5
Case 200 To 399
msngEarned = Val(txtCount) * 0.55
Case 400 To 599
msngEarned = Val(txtCount) * 0.6
Case Is >= 600
msngEarned = Val(txtCount) * 0.65
End Select

Thanks
Dale

Select Case
How would I make a select case so that whenever in a specified string there is one of the cases it does the assigned commands?

Select Case
Hi all. Please help.

I'm using a select case statement on 2 conditions namely on a controls left and top property. Here the code snippet:

Dim TopPos As Integer, LeftPos As Integer
TopPos = imgVideo(i).Top
LeftPos = imgVideo(i).Left
Select Case LeftPos And TopPos
Case LeftPos = 60, TopPos = 120
imgVideo(i).Top = TopPos - 60
Case LeftPos = 60, TopPos = 3480
imgVideo(i).Left = LeftPos + 60
Case LeftPos = 3840, TopPos = 120
imgVideo(i).Left = LeftPos - 60
Case LeftPos = 3840, TopPos = 3780
imgVideo(i).Top = TopPos - 60
End Select

The problem is that no case statement is executed. If I debug the program I see that the value of LeftPos = 60 and TopPos = 120, but the corresponding case statement isn't executed.

What could b the problem? Is my syntax wrong or what?
Thanks for the help.

Right$ In Select Case
I have the code belose in the LostFocus event of a combo box:
The combobox is populated from a Access Table.
For 2 of the dates there is a Matinee performance so in the combobox they are listed as 7/23/2005 MAT.
When the form is submitted there is a field in another table in the db where there is a date/time field for the date and a text field for the matinee.
I want to split string from the combo box in the event a matinee performance is selected so that the date selected can go into the date field in the proper format.

The Problem: When the date with "MAT" following it is selected in the combobox the select case falls past the case statement for that selection and on to the Case Else statment (where I get a Type Mis-Match error)

What syntax should I use to get this statement to work?

Code:
Private Sub cmbAttended_LostFocus()
'cmbattended.text=7/23/2005 MAT
Dim sDate() As String

Select Case cmbAttended.Text
Case "Mail In"
dDate = "NULL"
sMatMail = "Mail In"
Case Right(cmbAttended.Text, 3) = "MAT" '<---This is the wrong Syntax?
sDate = Split(cmbAttended.Text, " ")
dDate = CDate(sDate(0))
sMatMail = "Matinee"
Case Else
dDate = CDate(cmbAttended.Text)
sMatMail = "NULL"
End Select


End Sub

As always thank you in advance

Bart

Help With Select Case!!
There has to be a better way to preform this or just make it shorter... Anyone have any ideas?


Code:
Private Sub SetPiece_Index(CellIndex As Integer, PieceType As Pieces)
Select Case CellIndex
Case 1
SetPiece 1, 2, PieceType
Case 2
SetPiece 1, 4, PieceType
Case 3
SetPiece 1, 6, PieceType
Case 4
SetPiece 1, 8, PieceType
Case 5
SetPiece 2, 1, PieceType
Case 6
SetPiece 2, 3, PieceType
Case 7
SetPiece 2, 5, PieceType
Case 8
SetPiece 2, 7, PieceType
Case 9
SetPiece 3, 2, PieceType
Case 10
SetPiece 3, 4, PieceType
Case 11
SetPiece 3, 6, PieceType
Case 12
SetPiece 3, 8, PieceType
Case 13
SetPiece 4, 1, PieceType
Case 14
SetPiece 4, 3, PieceType
Case 15
SetPiece 4, 5, PieceType
Case 16
SetPiece 4, 7, PieceType
Case 17
SetPiece 5, 2, PieceType
Case 18
SetPiece 5, 4, PieceType
Case 19
SetPiece 5, 6, PieceType
Case 20
SetPiece 5, 8, PieceType
Case 21
SetPiece 6, 1, PieceType
Case 22
SetPiece 6, 3, PieceType
Case 23
SetPiece 6, 5, PieceType
Case 24
SetPiece 6, 7, PieceType
Case 25
SetPiece 7, 2, PieceType
Case 26
SetPiece 7, 4, PieceType
Case 27
SetPiece 7, 6, PieceType
Case 28
SetPiece 7, 8, PieceType
Case 29
SetPiece 8, 1, PieceType
Case 30
SetPiece 8, 3, PieceType
Case 31
SetPiece 8, 5, PieceType
Case 32
SetPiece 8, 7, PieceType
End Select

frmMain.Cell(CellIndex).Picture = frmMain.Images.ListImages.Item(PieceType).Picture
End Sub

Select Case
is there a better code for this?

Code:
Select Case MAIN64K.Label9(0).Caption
Case 0
lblcredit.Caption = "0"
Case 1
lblcredit.Caption = "1"
Case 2
lblcredit.Caption = "2"
Case 3
lblcredit.Caption = "3"
Case 4
lblcredit.Caption = "4"
Case 5
lblcredit.Caption = "5"
End Select
Select Case MAIN64K.Label9(1).Caption
Case 0
lblcredit.Caption = "0"
Case 1
lblcredit.Caption = "5"
Case 2
lblcredit.Caption = "10"
Case 3
lblcredit.Caption = "15"
Case 4
lblcredit.Caption = "20"
Case 5
lblcredit.Caption = "25"
End Select
Select Case MAIN64K.Label9(2).Caption
Case 0
lblcredit.Caption = "0"
Case 1
lblcredit.Caption = "10"
Case 2
lblcredit.Caption = "20"
Case 3
lblcredit.Caption = "30"
Case 4
lblcredit.Caption = "40"
Case 5
lblcredit.Caption = "50"
End Select
Select Case MAIN64K.Label9(3).Caption
Case 0
lblcredit.Caption = "0"
Case 1
lblcredit.Caption = "20"
Case 2
lblcredit.Caption = "40"
Case 3
lblcredit.Caption = "60"
Case 4
lblcredit.Caption = "80"
Case 5
lblcredit.Caption = "100"
End Select

Select Case
Is it possible to have 2 different values as the criteria for selection by case or must I use an If statement. I have 2 variables with and want to fill a third based on the 2.

I hope I explained this ok?

Select Case
16 text boxes named mix(0).text... mix(15).text

under the 'got focus' event, i want which ever text box that has the focus to then display the word "hello"

how would i write a select case statement for that?

i know the structure is something like:


Code:
Private Sub mix_GotFocus(Index As Integer)

Select Case name

case 1:

case 2:

End Sub

im not sure hwo to do it though in this instance. thanks in advance for any help!

Select Case
Can you help me with this please? Here is the code:
Dim intTotalPrice As Integer
intTotalPrice = txtReg.Text
Select Case intTotalPrice
Case optSem1.Value = True
lblTotal.Caption = intTotalPrice * 100
Case optSem1.Value = True And chkDisc.Value = True
lblTotal.Caption = (intTotalPrice * 100) - 0.1
Case optSem2.Value = True
lblTotal.Caption = intTotalPrice * 120
Case optSem2.Value = True And chkDisc.Value = True
lblTotal.Caption = (intTotalPrice * 120) - 0.01
End Select

What I have is a frame with 2 option buttons in it. And a check box with a 10% discount, not in the frame.

What I need it to do if option one then the cost is $100 * number entered. If option button 2 then $120 * number entered. and then if the 10% discount check box is checked then subtract .1 from the total.


Please help thanks

Select Case
Hello all... I need to do multiple things in one command button so how do I use the case select? Thanks in advance for some help its much appreciated

Case Select
Hi i'm using a set of case select statements.

I have

case "9:59": 'do something
case " 10:59" 'do something

I am wondering if i can have something like

case "9:59 to 10:58"

Thanks
Chris Lynch

Select Case
Please who can Explain how to use the Select Case control?

Select Case
Code:
Private Sub Command1_Click()
Dim strData As String
strData = Text1.Text
Select Case strData
Case Left$(strData, 3) = "msg"
MsgBox "MESSAGE!"
Case Left$(strData, 4) = "help"
MsgBox "help"
End Select
End Sub

this is not working for some reason... it works if I put
IF....THEN
but never worked with Select case... why? and how to make it work?

Select Case
I am having trouble using instr with a select case statement.
Code:
Select Case ValueOne
case (instr(1, ValueOne,"bewildered"))
dosomethinghere
case else
donothinghere
end select
I have tried code similar to the above with no success.
I'm not sure if this is possible, but cant figure out the value that goes
into the case line.

Select Case
is it good to have numbers of cases for a select statement.
I've got 25 cases for a single select case.

Select Case
I want to ignore the acceptable values and was hoping there was a shorter way to write this. I know I can use 3 to 5 in a case select, but is there a way to use (3 or 5 or 8 or 9)?
Anyway this is an example of the code I am hoping to condense.

Code:
Select myValue
Case 1
Case 4
Case 5
Case 9
Case 13
etc... etc..
Case Else
call errorRoutine
End Select

SELECT Case Help
hello again. can someone tell me whats wrong with this code please.

Thanks in advance!

Private Sub Timer1_Timer()
Select Case Winsock.State
Case 1
If Winsock.State = 7 Then lblStatus.Caption = "Connected " & IP
Case 2
If Winsock.State = 6 Then lblStatus.Caption = "Connecting to " & IP
Case 3
If Winsock.State = 3 Then lblStatus.Caption = "Pending connection to " & IP
Case Else
If Winsock.State = 9 Then lblStatus.Caption = "encountered error connection to " & IP
End Select
End Sub

Thanks!!!

Copyright © 2005-08 www.BigResource.com, All rights reserved