|
-
May 6th, 2003, 04:57 AM
#1
Thread Starter
Fanatic Member
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:
Private Sub cmdashft_Click()
Select Case Intwndprogress
Case Is = 10
txtinformation.Text = "J"
PicresultsShft.Print "Packers_Shift"; vbCrLf & CStr(txtinformation)
cmdashft.Caption = ""
cmdbshft.Caption = ""
cmdcshft.Caption = ""
cmddshft.Caption = ""
txtinformation.SetFocus
txtinformation.maxlength = 11
txtinformation = ""
Call wndprogres
End Select
Lbltext.Caption = "Please enter code"
validate_product_code
End Sub
Thanks
Last edited by holly; May 6th, 2003 at 07:04 AM.
** HOLLY ** 
-
May 6th, 2003, 05:06 AM
#2
Junior Member
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]
-
May 6th, 2003, 05:09 AM
#3
Thread Starter
Fanatic Member
The bit I want to change is the actually results which would be
printed on my form
VB Code:
txtinformation.Text = "J"
PicresultsShft.Print "Packers_Shift"; vbCrLf & CStr(txtinformation)
depending on which button is pressed - txtinformation could be J
,A, B, G etc
Thanks
** HOLLY ** 
-
May 6th, 2003, 05:11 AM
#4
Junior Member
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]
-
May 6th, 2003, 05:14 AM
#5
Thread Starter
Fanatic Member
-
May 6th, 2003, 05:23 AM
#6
Junior Member
Hi Holly,
Ok... I'll try to give you the code I think is the best:
VB Code:
Public Letter As String
Private Sub CommandButton_Click(Index As Integer)
'Remember that the first CommandButton in the array is
'ALWAYS 0
If Index = 0 Then
Letter = "J"
ElseIf Index = 1 Then
Letter = "A"
ElseIf Index = 2 Then
Letter = "B"
ElseIf Index = 3 Then
Letter = "G"
End If
txtInformation.Text = Letter
PicresultsShft.Print "Packers_Shift"; vbCrLf & CStr(txtinformation)
Call wndprogres
Lbltext.Caption = "Please enter code"
validate_product_code
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]
-
May 6th, 2003, 05:26 AM
#7
Thread Starter
Fanatic Member
-
May 6th, 2003, 05:46 AM
#8
Junior Member
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]
-
May 6th, 2003, 06:45 AM
#9
VB Code:
Select Case Index
Case 0
Case 1
Case 2
.
.
.
Case Else
End Select
-
May 6th, 2003, 07:04 AM
#10
Thread Starter
Fanatic Member
-
May 6th, 2003, 08:13 AM
#11
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|