Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help file Creation in Visual Basic

Bama58Bama58 Member Posts: 15
I used Select Case Index and I have only been able to get it to work if I choose one case (i.e. swing path is "in to out") and the GUI tells the user the "ball starts to the right of the target". If I choose two (i.e. swing path is "in to out" and clubface alignment is "open") my result is only picking up the swing path, rather than telling the user the "ball starts to the right and continues to curve to the right of the target". can anyone help me figure out why I am unable to pick two cases?

Object: I have two boxes the user can choose from:

Swing Path Clubface alignment
o In to Out o Open
o Down the Line o Way too open
o Out to in o Square
o Closed
o Way too Closed
Display swing results Exit

****************************************************************************
*******
My code is:
Dim ThisIcon
****************************************************************************
*******
Private sub cmdDisplay_Click( )
txtresults.text = ThisIcon
end sub
****************************************************************************
********
Private sub cmdExit_click( )
Unload me
End Sub
****************************************************************************
********
Private sub opticon_Click(Index as Integer)
Select Case Index
Case 0 and 3 (0 is swing path "in to out"; 3 club alignment
"open")
This icon = "Ball starts to the right and continues
curving to the right of target!"

Case 0 and 4 (0 is swing path "in to out"; 3 club alignment
"way too open")
This icon = "Ball starts to the right and curves a
lot to the left of the target!"

(When I choose both Cases the result is only picking up Case 0 (i.e. swing path.) There are 15 possibilities.

Comments

  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    : I used Select Case Index and I have only been able to get it to work if I choose one case (i.e. swing path is "in to out") and the GUI tells the user the "ball starts to the right of the target". If I choose two (i.e. swing path is "in to out" and clubface alignment is "open") my result is only picking up the swing path, rather than telling the user the "ball starts to the right and continues to curve to the right of the target". can anyone help me figure out why I am unable to pick two cases?
    :[code]
    : Object: I have two boxes the user can choose from:
    :
    : Swing Path Clubface alignment
    : o In to Out o Open
    : o Down the Line o Way too open
    : o Out to in o Square
    : o Closed
    : o Way too Closed
    : Display swing results Exit
    :
    : ****************************************************************************
    : *******
    : My code is:
    : Dim ThisIcon
    : ****************************************************************************
    : *******
    : Private sub cmdDisplay_Click( )
    : txtresults.text = ThisIcon
    : end sub
    : ****************************************************************************
    : ********
    : Private sub cmdExit_click( )
    : Unload me
    : End Sub
    : ****************************************************************************
    : ********
    : Private sub opticon_Click(Index as Integer)
    : Select Case Index
    : Case 0 and 3 (0 is swing path "in to out"; 3 club alignment
    : "open")
    : This icon = "Ball starts to the right and continues
    : curving to the right of target!"
    :
    : Case 0 and 4 (0 is swing path "in to out"; 3 club alignment
    : "way too open")
    : This icon = "Ball starts to the right and curves a
    : lot to the left of the target!"
    : [/code]
    : (When I choose both Cases the result is only picking up Case 0 (i.e. swing path.) There are 15 possibilities.
    :

    Your code cannot handle what you want. How are your controls structured? I will show an example with two option arrays; one is called optSwing, the other is called optAlign. Also have a label called lblResults.
    [code]
    Private IndexSwing As Integer
    Private IndexAlign As Integer
    Private Sub optSwing_Click(Index As Integer)

    IndexSwing = Index
    lblResults.Caption = GetSwing(IndexSwing) & GetAlign(IndexAlign)

    End Sub
    Private Sub optAlign_Click(Index As Integer)

    IndexAlign = Index
    lblResults.Caption = GetSwing(IndexSwing) & GetAlign(IndexAlign)

    End Sub
    Private Function GetSwing(ByVal Index As Integer) As String

    Select Case Index
    Case 0
    GetSwing = "In to Out"
    Case 1
    GetSwing = "Down the Line"
    Case 2
    GetSwing = "Out to in"
    End Select

    End Function
    Private Function GetAlign(ByVal Index As Integer) As String

    Select Case Index
    Case 0
    GetAlign = "Open"
    Case 1
    GetAlign = "Way too open"
    Case 2
    GetAlign = "Square"
    Case 3
    GetAlign = "Closed"
    Case 4
    GetAlign = "Way too Closed"
    End Select

    End Function
    [/code]
    Just replace with the appropriate text...
  • Bama58Bama58 Member Posts: 15
    Thanks,

    I tried your code and was unable to get it to display the results in the results box. My GUI is set up that after you pick a factor in both Swing and Align you press the display command button and results are shown in a text box.

    I worked with your application and did get it to show results but it only shows the results for Case 0 in Swing and Align. I used the following:

    Private Sub cmdDisplay_Click()
    txtresults.Text = GetSwing & GetAlign
    End Sub

    The only way I could get any result displayed was to change the GetSwing and GetAlign Function - I couldn't use the
    (ByVal Index As Integer) As String

    That was the only change I made...

    Noticed you were from Boaz Alabama - I'm from Huntsville, Alabama
  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    : Thanks,
    :
    : I tried your code and was unable to get it to display the results in the results box. My GUI is set up that after you pick a factor in both Swing and Align you press the display command button and results are shown in a text box.
    :
    : I worked with your application and did get it to show results but it only shows the results for Case 0 in Swing and Align. I used the following:
    :
    : Private Sub cmdDisplay_Click()
    : txtresults.Text = GetSwing & GetAlign
    : End Sub
    :
    : The only way I could get any result displayed was to change the GetSwing and GetAlign Function - I couldn't use the
    : (ByVal Index As Integer) As String
    :
    : That was the only change I made...
    :
    : Noticed you were from Boaz Alabama - I'm from Huntsville, Alabama
    :

    <<... I couldn't use the (ByVal Index As Integer) As String ...>>

    That is because you were not passing the indices of the selected options to the functions. Here is an alternative that will be larger and slower (when compiled) but will work the way you are using them.

    1. Remove the two Private lines from the beginning of my example.
    2. Remove the code from the two opt*_Click events.
    3. Change GetSwing And GetAlign to:
    [code]
    Private Function GetSwing() As String

    Dim I As Long
    For I = 0 To 2
    If optSwing(I).Value = 1 Then Exit For
    Next
    If I = 3 Then
    MsgBox "You must select a swing!", vbCritical
    Exit Function
    End If
    Select Case I
    Case 0
    GetSwing = "In to Out"
    Case 1
    GetSwing = "Down the Line"
    Case 2
    GetSwing = "Out to in"
    End Select

    End Function
    Private Function GetAlign() As String

    Dim I As Long
    For I = 0 To 4
    If optAlign(I).Value = 1 Then Exit For
    Next
    If I = 5 Then
    MsgBox "You must select an alignment!", vbCritical
    Exit Function
    End If
    Select Case I
    Case 0
    GetAlign = "Open"
    Case 1
    GetAlign = "Way too open"
    Case 2
    GetAlign = "Square"
    Case 3
    GetAlign = "Closed"
    Case 4
    GetAlign = "Way too Closed"
    End Select

    End Function
    [/code]
    My previous example stored the current index when it was selected and passed it to the functions. In this example, the functions search for the current index.
  • Shawn CarterShawn Carter Member Posts: 0

    _____ / http://forcoder.org / free ebooks and video tutorials about // MATLAB, C, PL/SQL, Swift, PHP, Java, Perl, C++, Assembly, Ruby, R, C#, Go, Scratch, JavaScript, Visual Basic .NET, Python, Delphi, Visual Basic, Objective-C ABAP, Hack, Logo, Apex, Lisp, Prolog, Lua, Dart, FoxPro, Fortran, Clojure, Bash, LabVIEW, Scala, Julia, F#, Ada, Erlang, Awk, COBOL, Crystal, Rust, Kotlin, D, Scheme, Alice, VBScript, SAS, ML, Transact-SQL // _____________

Sign In or Register to comment.