Results 1 to 11 of 11

Thread: Resolved - Cmd Button Array

  1. #1

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721

    Resolved - Cmd Button Array

    Hi
    I do not know much about arrays but I have 4 cmd buttons on my
    form these will do exactly the same except for the printed results
    which will be a little different i.e

    How can I put this into an array but change the printed result
    depending on which button is pressed

    my code
    VB Code:
    1. Private Sub cmdashft_Click()
    2.  
    3.         Select Case Intwndprogress
    4.             Case Is = 10
    5.                 txtinformation.Text = "J"
    6.                 PicresultsShft.Print "Packers_Shift"; vbCrLf & CStr(txtinformation)
    7.                     cmdashft.Caption = ""
    8.                     cmdbshft.Caption = ""
    9.                     cmdcshft.Caption = ""
    10.                     cmddshft.Caption = ""
    11.     txtinformation.SetFocus
    12.     txtinformation.maxlength = 11
    13.     txtinformation = ""
    14.              Call wndprogres
    15.                
    16.        End Select
    17.       Lbltext.Caption = "Please enter code"
    18.             validate_product_code
    19.  
    20. End Sub

    Thanks
    Last edited by holly; May 6th, 2003 at 07:04 AM.
    ** HOLLY **

  2. #2
    Junior Member
    Join Date
    May 2003
    Posts
    17
    Hi,

    May I ask whát exactly do you want to be changed when a cmd-button is pressed?

    Greetings,

    Teddo
    [vbcode]
    Private Sub AskAQuestion(Me As Question, Others As Answer)
    MsgBox "Answer: " & Others
    End Sub

    Private Sub HelpOthers()
    If Answer = Known Then
    Give Answer
    Else
    MakeUpAnswerAndLookSmart
    End If
    End Sub
    [/vbcode]
    [vbcode]
    Private Sub Teddo_WakeUp()
    If HelpOther = Possible Then
    HelpOthers
    Else
    AskAQuestion
    End If
    End Sub
    [/vbcode]

  3. #3

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    The bit I want to change is the actually results which would be
    printed on my form
    VB Code:
    1. txtinformation.Text = "J"
    2.                 PicresultsShft.Print "Packers_Shift"; vbCrLf & CStr(txtinformation)

    depending on which button is pressed - txtinformation could be J
    ,A, B, G etc

    Thanks
    ** HOLLY **

  4. #4
    Junior Member
    Join Date
    May 2003
    Posts
    17
    Hi,

    Erm...
    Do you want that only the letters that you said can be chosen or do you want it to choose one of the letters from the alphabet?

    Greetz,
    Teddo
    [vbcode]
    Private Sub AskAQuestion(Me As Question, Others As Answer)
    MsgBox "Answer: " & Others
    End Sub

    Private Sub HelpOthers()
    If Answer = Known Then
    Give Answer
    Else
    MakeUpAnswerAndLookSmart
    End If
    End Sub
    [/vbcode]
    [vbcode]
    Private Sub Teddo_WakeUp()
    If HelpOther = Possible Then
    HelpOthers
    Else
    AskAQuestion
    End If
    End Sub
    [/vbcode]

  5. #5

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    I want the letters that I have mentioned!!!
    ** HOLLY **

  6. #6
    Junior Member
    Join Date
    May 2003
    Posts
    17
    Hi Holly,

    Ok... I'll try to give you the code I think is the best:

    VB Code:
    1. Public Letter As String
    2.  
    3. Private Sub CommandButton_Click(Index As Integer)
    4. 'Remember that the first CommandButton in the array is
    5. 'ALWAYS 0
    6.  If Index = 0 Then
    7.    Letter = "J"
    8.  ElseIf Index = 1  Then
    9.    Letter = "A"
    10.  ElseIf Index = 2 Then
    11.    Letter = "B"
    12.  ElseIf Index = 3 Then
    13.    Letter = "G"
    14.  End If
    15. txtInformation.Text = Letter
    16. PicresultsShft.Print "Packers_Shift"; vbCrLf & CStr(txtinformation)
    17.  
    18. Call wndprogres
    19.                
    20.     Lbltext.Caption = "Please enter code"
    21.           validate_product_code
    22.  
    23.  
    24. End Sub

    I'm not completely sure whether it works, but you can try!!!
    If it doesn't, I'm sorry

    Greetz,


    :::Teddo:::
    [vbcode]
    Private Sub AskAQuestion(Me As Question, Others As Answer)
    MsgBox "Answer: " & Others
    End Sub

    Private Sub HelpOthers()
    If Answer = Known Then
    Give Answer
    Else
    MakeUpAnswerAndLookSmart
    End If
    End Sub
    [/vbcode]
    [vbcode]
    Private Sub Teddo_WakeUp()
    If HelpOther = Possible Then
    HelpOthers
    Else
    AskAQuestion
    End If
    End Sub
    [/vbcode]

  7. #7

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Thanks Teddo, I will give it ago and let you know how I get on!!
    Thanks for all your help


    ** HOLLY **

  8. #8
    Junior Member
    Join Date
    May 2003
    Posts
    17
    Hi Holly,

    No problem....
    Usually I always ask questions, but this was something I knew!!(just from books etc.)
    So I am glad I could help you...

    Sorry for my late response, but I was away for Lunch...

    Greetz and lots of luck,

    Teddo
    [vbcode]
    Private Sub AskAQuestion(Me As Question, Others As Answer)
    MsgBox "Answer: " & Others
    End Sub

    Private Sub HelpOthers()
    If Answer = Known Then
    Give Answer
    Else
    MakeUpAnswerAndLookSmart
    End If
    End Sub
    [/vbcode]
    [vbcode]
    Private Sub Teddo_WakeUp()
    If HelpOther = Possible Then
    HelpOthers
    Else
    AskAQuestion
    End If
    End Sub
    [/vbcode]

  9. #9
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    VB Code:
    1. Select Case Index
    2. Case 0
    3.  
    4. Case 1
    5.  
    6. Case 2
    7. .
    8. .
    9. .
    10. Case Else
    11.  
    12. End Select

  10. #10

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Thanks Teddo,
    After a bit of tweaking - I manged to get it to work.......

    Thanks again for all your help

    ** HOLLY **

  11. #11
    Junior Member
    Join Date
    May 2003
    Posts
    17
    No problem, like I said before!!!!!!!

    [vbcode]
    Private Sub AskAQuestion(Me As Question, Others As Answer)
    MsgBox "Answer: " & Others
    End Sub

    Private Sub HelpOthers()
    If Answer = Known Then
    Give Answer
    Else
    MakeUpAnswerAndLookSmart
    End If
    End Sub
    [/vbcode]
    [vbcode]
    Private Sub Teddo_WakeUp()
    If HelpOther = Possible Then
    HelpOthers
    Else
    AskAQuestion
    End If
    End Sub
    [/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width