darold_rudolph
asked on
Input Box with Radio Buttons
I need an "InputBox" with Radio Buttons instead of the textBox in the VB "InputBox" control
It needs to behave the similar to the VB "Input Box" control.
I need to pass the 4 or 5 captions, set a defaul, pass control to the "Input Box" wait until the User presses OK and retrieve the result back into the main program. The main program then continues.
The questions for the input box differ at different times.
I have had no luck with vbmodal forms. Can't pass the captions, before displaying modal form.
I have had no luck with vbModeless forms. Does pass control to the input form and pause the main program.
I have researched this a bit. I can't find a simple answer, so there must be a trick
Any suggestions?????????
It needs to behave the similar to the VB "Input Box" control.
I need to pass the 4 or 5 captions, set a defaul, pass control to the "Input Box" wait until the User presses OK and retrieve the result back into the main program. The main program then continues.
The questions for the input box differ at different times.
I have had no luck with vbmodal forms. Can't pass the captions, before displaying modal form.
I have had no luck with vbModeless forms. Does pass control to the input form and pause the main program.
I have researched this a bit. I can't find a simple answer, so there must be a trick
Any suggestions?????????
Hi
You can use 2 ways:
1. Declare Captions names as Public in Bas module:
Public Cap1 As String, Cap2 As String.....
At Input_Form_Load Event:
Option1.Caption = Cap1
Option2.Caption = Cap2
And before calling this form:
Cap1 = "anycap1"
Cap2 = "anycap2"
2. Use Publi Property Let/Get construction inside Input_Form
Cheers
You can use 2 ways:
1. Declare Captions names as Public in Bas module:
Public Cap1 As String, Cap2 As String.....
At Input_Form_Load Event:
Option1.Caption = Cap1
Option2.Caption = Cap2
And before calling this form:
Cap1 = "anycap1"
Cap2 = "anycap2"
2. Use Publi Property Let/Get construction inside Input_Form
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry:
MsgBox FormName.InputOption(App.T itle ...
One other thing: I included code to let you show a prompt on a label. Remove it if you don't need a label for longer instructions.
MsgBox FormName.InputOption(App.T
One other thing: I included code to let you show a prompt on a label. Remove it if you don't need a label for longer instructions.
'Add a form
Name = frmSingleSelect
BorderStyle = 3 'Fixed Dialog
'Add a option button
Name = opt
Index = 0
'Add a command button
Name = cmdOK
Caption = &OK
Default = True
'Add another command button
Name = cmdCancel
Caption = &Cancel
Cancel = True
'Code like this
Option Explicit
Private Const LNG_GAP = 120
Private m_bReturn As Boolean
Private m_lIndex As Long
Public Function Action(ByRef Index As Long, ParamArray Captions()) As Boolean
Dim lUBound As Long
Dim I As Long
Load Me
m_bReturn = False
m_lIndex = -1
lUBound = UBound(Captions)
For I = 0 To lUBound
If I > 0 Then
Load opt(I)
opt(I).Top = opt(I - 1).Top + opt(I - 1).Height + LNG_GAP
opt(I).Visible = True
End If
opt(I).Caption = Captions(I)
Next
opt(Index).Value = True
m_lIndex = Index
Me.Show vbModal
If m_bReturn Then
Index = m_lIndex
End If
Action = m_bReturn
End Function
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
m_bReturn = True
Unload Me
End Sub
Private Sub opt_Click(Index As Integer)
m_lIndex = Index
End Sub
'and the calling code
Dim lIndex As Long
lIndex = 0
If frmSingleSelect.Action(lIn dex, "Top", "Right", "Bottom", "Left") Then
Select Case lIndex
Case 0: Debug.Print "Top"
Case 1: Debug.Print "Right"
Case 2: Debug.Print "Bottom"
Case 3: Debug.Print "Left"
End Select
End If
Name = frmSingleSelect
BorderStyle = 3 'Fixed Dialog
'Add a option button
Name = opt
Index = 0
'Add a command button
Name = cmdOK
Caption = &OK
Default = True
'Add another command button
Name = cmdCancel
Caption = &Cancel
Cancel = True
'Code like this
Option Explicit
Private Const LNG_GAP = 120
Private m_bReturn As Boolean
Private m_lIndex As Long
Public Function Action(ByRef Index As Long, ParamArray Captions()) As Boolean
Dim lUBound As Long
Dim I As Long
Load Me
m_bReturn = False
m_lIndex = -1
lUBound = UBound(Captions)
For I = 0 To lUBound
If I > 0 Then
Load opt(I)
opt(I).Top = opt(I - 1).Top + opt(I - 1).Height + LNG_GAP
opt(I).Visible = True
End If
opt(I).Caption = Captions(I)
Next
opt(Index).Value = True
m_lIndex = Index
Me.Show vbModal
If m_bReturn Then
Index = m_lIndex
End If
Action = m_bReturn
End Function
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
m_bReturn = True
Unload Me
End Sub
Private Sub opt_Click(Index As Integer)
m_lIndex = Index
End Sub
'and the calling code
Dim lIndex As Long
lIndex = 0
If frmSingleSelect.Action(lIn
Select Case lIndex
Case 0: Debug.Print "Top"
Case 1: Debug.Print "Right"
Case 2: Debug.Print "Bottom"
Case 3: Debug.Print "Left"
End Select
End If
Gee, that kinda looks familiar...
ASKER
KDivad had the answer first
ASKER
This was exactly what I as looking for, Thanks. Your reponse was complete.
Also the Call statement of:
intResponse = frmForm1.InputOption(App.T itle, "Please select an option:", "Option 1", "Option 2", "Option 3", "Option 4")
allows me to use the intResponse value of -1 or 0 to 3 in my calling program.
Thanks again!
I love this! I get answer while I sleep! No Worries!
Thanks everyone for responding!
Also the Call statement of:
intResponse = frmForm1.InputOption(App.T
allows me to use the intResponse value of -1 or 0 to 3 in my calling program.
Thanks again!
I love this! I get answer while I sleep! No Worries!
Thanks everyone for responding!
<< I love this! I get answer while I sleep! No Worries! >>
That's why us insomniacs are here! <grin>
I'm glad I could help you out!
Later,
KDL
That's why us insomniacs are here! <grin>
I'm glad I could help you out!
Later,
KDL
Whatever code you have in the Form_Load should probably go in Form_Activate; you may want to use some form-level public variables to control the return values, etc. and have the calling form check those to see their status.
Describe a bit about the event procedures you use...