Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio Button Coding for Sending Strings to Screen 2

Status
Not open for further replies.

jamminbuddha

Technical User
Aug 3, 2008
5
0
0
US
Hi!

I am working on a macro that presents a user 11 option/radio buttons. Depending on the one they choose, the text associated with that button in the Case options will be sent to the screen.

The closest example I found was in another post showing how Push Buttons work as opposed to radio buttons.
See below:

Sub Main

Dim System As Object
Dim Sess As Object
Set System = CreateObject("EXTRA.System")
Set Sess = System.ActiveSession
Begin Dialog UserDialog 23, 26, 86, 62, "New DACs"
ButtonGroup .AllButtons
PushButton 0, 0, 84, 18, "New DACs Required"
PushButton 0, 20, 84, 18, "Double DACs"
PushButton 0, 40, 84, 20, "B1 Unsuitable"
End Dialog

Dim optsdialog as UserDialog
ichoice = Dialog(optsdialog)

Select Case ichoice
Case 1
Sess.Screen.SendKeys("Some text")
Case 2
Sess.Screen.SendKeys("Some text")
Case 3
Sess.Screen.SendKeys("Some text")
End Select
End Sub

How can I code this so that radio buttons are used instead?
I played around with inserting this code in my own program coding, but not knowing the radio button programming it failed. There also seemed to be some conflict with the declarations in this part of the above code:
Dim optsdialog as UserDialog
ichoice = Dialog(optsdialog)

with my own declarations about my Dialog box. I altered them to correspond but it didn't work.

Below is my own coding for my Dialog box for reference as well. I didn't include my whole code, but can if need be. It is a tad bit messy as I am learning this as I go and have copied and tweaked existing code for my needs.

Begin Dialog UserDialog 185, 52, 280, 174, "Share Aging"
TextBox 95, 5, 51, 13, .freeshrbox
TextBox 95, 19, 51, 13, .tfrdatebox
TextBox 95, 32, 51, 13, .redfeedatebox
TextBox 95, 46, 51, 13, .navpricebox
OptionGroup .OptionGroup1
OptionButton 10, 79, 46, 10, "Purchases", .OptionButton4
OptionButton 10, 95, 60, 10, "Purchases A+", .OptionButton1
OptionButton 10, 110, 60, 10, "Free Side Load", .OptionButton2
OptionButton 10, 130, 45, 10, "Dividends", .OptionButton3
OptionButton 90, 85, 46, 10, "Purchases", .OptionButton5
OptionButton 90, 102, 65, 10, "Free Side Load", .OptionButton6
OptionButton 90, 119, 50, 10, "Dividends", .OptionButton7
OptionButton 180, 80, 80, 11, "Purchases (Liable)", .OptionButton8
OptionButton 180, 97, 95, 11, "Purchases (Not Liable)", .OptionButton9
OptionButton 180, 114, 65, 10, "Free Side Load", .OptionButton10
OptionButton 180, 131, 44, 10, "Dividends", .OptionButton11
TextBox 95, 149, 53, 13, .microbox
OkButton 170, 148, 36, 14
CancelButton 215, 148, 36, 14
GroupBox 5, 65, 74, 80, "A Shares"
Text 28, 154, 54, 8, "Micro Ref # Date"
GroupBox 85, 65, 85, 80, "B Shares"
GroupBox 170, 65, 110, 80, "C Shares"
Text 20, 5, 65, 10, "Adj Free Shares"
Text 18, 21, 65, 8, "Transfer/Purch Date"
Text 19, 49, 65, 8, "NAV Price", .navprice
Text 20, 35, 65, 8, "Red Fee Liable Date"
Picture 181, 12, 77, 39, "C:\Program Files\E!PC\ben 256.bmp", 0
End Dialog



Any guidance that anyone can provide will be greatly appreciated. My searches through this forum and the Extra Help files have not been enough to get me over this roadblock.

Thank you
 
Does this help? This is what i've done in the past
Instead of the array you can use if statements or case statements if you are more comfortable with those.
Code:
Sub Main


Dim System As Object
Dim Sess As Object
Set System = CreateObject("EXTRA.System")
Set Sess = System.ActiveSession

Dim arOptButton(10) as string 
Dim x as integer

Begin Dialog UserDialog 185, 52, 280, 174, "Share Aging"
   TextBox  95, 5, 51, 13, .freeshrbox
   TextBox  95, 19, 51, 13, .tfrdatebox
   TextBox  95, 32, 51, 13, .redfeedatebox
   TextBox  95, 46, 51, 13, .navpricebox
   OptionGroup.optiongroup1
      OptionButton  10, 79, 46, 10, "Purchases", .OptionButton4
      OptionButton  10, 95, 60, 10, "Purchases A+", .OptionButton1
      OptionButton  10, 110, 60, 10, "Free Side Load", .OptionButton2
      OptionButton  10, 130, 45, 10, "Dividends", .OptionButton3
      OptionButton  90, 85, 46, 10, "Purchases", .OptionButton5
      OptionButton  90, 102, 65, 10, "Free Side Load", .OptionButton6
      OptionButton  90, 119, 50, 10, "Dividends", .OptionButton7
      OptionButton  180, 80, 80, 11, "Purchases (Liable)", .OptionButton8
      OptionButton  180, 97, 95, 11, "Purchases (Not Liable)", .OptionButton9
      OptionButton  180, 114, 65, 10, "Free Side Load", .OptionButton10
      OptionButton  180, 131, 44, 10, "Dividends", .OptionButton11
   TextBox  95, 149, 53, 13, .microbox
   OkButton  170, 148, 36, 14
   CancelButton  215, 148, 36, 14
   GroupBox  5, 65, 74, 80, "A Shares"
   Text  28, 154, 54, 8, "Micro Ref # Date"
   GroupBox  85, 65, 85, 80, "B Shares"
   GroupBox  170, 65, 110, 80, "C Shares"
   Text  20, 5, 65, 10, "Adj Free Shares"
   Text  18, 21, 65, 8, "Transfer/Purch Date"
   Text  19, 49, 65, 8, "NAV Price", .navprice
   Text  20, 35, 65, 8, "Red Fee Liable Date"
   
End Dialog

Dim optsdialog as UserDialog

arOptButton(0)="Purchases"
arOptButton(1)="Purchases A+"
arOptButton(2)="Free Side Load"
arOptButton(3)="Dividends"
arOptButton(4)="Purchases"
arOptButton(5)="Free Side Load"
arOptButton(6)="Dividends"
arOptButton(7)="Purchases (Liable)"
arOptButton(8)="Purchases (Not Liable)"
arOptButton(9)="Free Side Load"
arOptButton(10)="Dividends"


Dialog optsdialog

    

x= optsdialog.OptionGroup1
           

    
Sess.Screen.Sendkeys(arOptButton(x))  


Set Sess=nothing
Set System=nothing

End Sub
 
Thanks so much for your help and responding. I am not too well versed in either Select Case or If/Then statements so I am still challenged here.

In addition to what I stated before, I need to be able to send more than one string of text at different positions on the screen so your suggestion doesn't quite work for me.

For example:

Selecting the first radio button, "Purchases" needs to send "N", "Y", "Y", "C", "2", "Y" (with each letter in a different screen position)

If a different radio button is selected, text needs to be sent to the same locations as "Purchases" but the data will be different.

See below:

myscreen.MoveTo 9,19
myscreen.SendKeys("n")
myscreen.MoveTo 9,40
myscreen.SendKeys("y")
myscreen.MoveTo 9,68
myscreen.SendKeys("y")

For complete clarity I have added in my entire code.

'-------------------------------------------------------------------------------------
' Macro Name: Share Aging Macro
'
'-------------------------------------------------------------------------------------

Sub Main

' Variable Declarations

Dim Sessions As Object
Dim System As Object
dim myscreen as object
dim myarea as object
dim curscreen as string
dim micro as string
dim x as integer
dim freeshr as string

dim tfrdate as string
dim navprice as string
dim amnt as single
dim fund as string
dim redfeedate as string
dim lottype as string
dim category as string
dim currentdate as string


Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If


' Set the default wait timeout value
g_HostSettleTime = 500 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE

' This section of code contains the recorded events

set myscreen = sess0.screen
myline = myscreen.row

'--------------------------------------------------------------------------------------

Begin Dialog UserDialog 185, 52, 280, 174, "Share Aging"
TextBox 95, 5, 51, 13, .freeshrbox
TextBox 95, 19, 51, 13, .tfrdatebox
TextBox 95, 32, 51, 13, .redfeedatebox
TextBox 95, 46, 51, 13, .navpricebox
OptionGroup .OptionGroup1
OptionButton 10, 79, 46, 10, "Purchases", .OptionButton4
OptionButton 10, 95, 60, 10, "Purchases A+", .OptionButton1
OptionButton 10, 110, 60, 10, "Free Side Load", .OptionButton2
OptionButton 10, 130, 45, 10, "Dividends", .OptionButton3
OptionButton 90, 85, 46, 10, "Purchases", .OptionButton5
OptionButton 90, 102, 65, 10, "Free Side Load", .OptionButton6
OptionButton 90, 119, 50, 10, "Dividends", .OptionButton7
OptionButton 180, 80, 80, 11, "Purchases (Liable)", .OptionButton8
OptionButton 180, 97, 95, 11, "Purchases (Not Liable)", .OptionButton9
OptionButton 180, 114, 65, 10, "Free Side Load", .OptionButton10
OptionButton 180, 131, 44, 10, "Dividends", .OptionButton11
TextBox 95, 149, 53, 13, .microbox
OkButton 170, 148, 36, 14
CancelButton 215, 148, 36, 14
GroupBox 5, 65, 74, 80, "A Shares"
Text 28, 154, 54, 8, "Micro Ref # Date"
GroupBox 85, 65, 85, 80, "B Shares"
GroupBox 170, 65, 110, 80, "C Shares"
Text 20, 5, 65, 10, "Adj Free Shares"
Text 18, 21, 65, 8, "Transfer/Purch Date"
Text 19, 49, 65, 8, "NAV Price", .navprice
Text 20, 35, 65, 8, "Red Fee Liable Date"
Picture 181, 12, 77, 39, "C:\Program Files\E!PC\ben 256.bmp", 0
End Dialog







'---------------------------------------------------------------------------------------

' This section of code contains the necessary actions

iDone = FALSE


curscreen = myscreen.getstring(1,5,4)
rem indate=CVar(Date)
rem outdate = Format(indate,"mmddyy")


While (iDone = FALSE)
Dim dMain as UserDialog

nRet = Dialog(dMain)

Select Case nRet
Case -1 '-1 is returned if user chooses OK
freeshr = trim(dMain.freeshrbox)
micro = trim(dMain.Microbox)
currdate = CVar(Date)
tfrdate = trim(Dmain.tfrdatebox)
redfeedate = trim(Dmain.redfeedatebox)
navprice = trim(Dmain.navpricebox)
iDone = TRUE
test = len(freeshr)
If test = 0 then
iDone = FALSE
bad = msgbox("Enter share amount",0)
End if
rem If micro = "" then
rem iDone = FALSE
rem bad = msgbox("Input a Micro Reference #!!",0)
rem End If

Select Case curscreen
case "LOTM"
' Moves cursor to MICRO REF field and clears it out.
myscreen.MoveTo 11,15
myscreen.SendKeys ("<EraseEOF>")

' Moves cursor to ADJ FREE SHARES field and inputs share amount.
myscreen.MoveTo 8,19
myscreen.SendKeys(freeshr)

' Moves cursor to ORIG EFF DATE field and inputs transfer date.
myscreen.MoveTo 10,19
myscreen.SendKeys(tfrdate)

' Moves cursor to 12B1 AGE DTE field and inputs transfer date.
myscreen.MoveTo 10,40
myscreen.SendKeys(tfrdate)

' Moves cursor to RED FEE AGE DTE field and inputs transfer date.
myscreen.MoveTo 10,68
myscreen.SendKeys(redfeedate)


' Moves cursor to MICRO REF field and inputs microref # including current date.
myscreen.WaitHostQuiet(g_HostSettleTime)
myscreen.MoveTo 11,15
If micro = "" then
rem iDone = FALSE
rem bad = msgbox("Input a Micro Reference #!!",0)
rem End If
myscreen.SendKeys ("779 RPT " & currdate)
Else
myscreen.SendKeys(micro)

End If

' Moves cursor to ORIG SHARES field and inputs share amount.
myscreen.WaitHostQuiet(g_HostSettleTime)
myscreen.MoveTo 16,15
myscreen.SendKeys(freeshr)

' Moves cursor to SHARES REMAIN field and inputs share amount.
myscreen.WaitHostQuiet(g_HostSettleTime)
myscreen.MoveTo 17,15
myscreen.SendKeys(freeshr)

' Moves cursor to PRICE field and inputs share amount.
myscreen.WaitHostQuiet(g_HostSettleTime)
myscreen.MoveTo 17,31
myscreen.SendKeys(navprice)

' Gets fund number and inputs it into FND field.
fund = myscreen.getstring(4,23,3)
myscreen.WaitHostQuiet(g_HostSettleTime)
myscreen.MoveTo 16,47
myscreen.SendKeys(fund)

' Gets ORIG EFF DATE and sends the data to the AGE DATE field.
' The date is then formatted into the mm/dd/yy format.
mnthagedate = myscreen.getstring(10,19,2)
dayagedate = myscreen.getstring(10,21,2)
yearagedate = myscreen.getstring(10,23,2)
myscreen.MoveTo 16,3
myscreen.SendKeys(mnthagedate & "/" & dayagedate & "/20" & yearagedate)


' Gets RED FEE AGE DTE and sends the data to the RED AGE DT field.
' The date is then formatted into the mm/dd/yy format.
mnthagedate_b = myscreen.getstring(10,68,2)
dayagedate_b = myscreen.getstring(10,70,2)
yearagedate_b = myscreen.getstring(10,72,2)
myscreen.MoveTo 17,56
myscreen.SendKeys(mnthagedate_b & "/" & dayagedate_b & "/20" & yearagedate_b)

' Determines the AMOUNT by multiplying the "freeshr" variable by the "navprice" variable.
' The "amnt" variable will then be sent to the AMOUNT field.
freeshrdouble = Val(freeshr)
navpricedouble = Val(navprice)
amnt = (freeshrdouble * navpricedouble)
rem amnt = CCur(amnt)
amt = Format(amnt, "#.#")
myscreen.MoveTo 16,31
myscreen.SendKeys(amnt)

' Sends information to necessary fields for lot type based upon the radio button selected.

' THIS IS WHERE I NEED THE CODE FOR SENDING THE TEXT TO VARIOUS POSITIONS
' ON THE SCREEN



case Else
bad = msgbox("Not a valid option screen. Please use macro only while on the MFTLOTM screen", 0)
iDone = FALSE
end select

Case 0 ' 0 is returned if the user chose Cancel
iDone = TRUE
End Select
Wend
End Sub
 
how about this?
Code:
Sub Main

Dim System As Object
Dim Sess As Object
Set System = CreateObject("EXTRA.System")
Set Sess = System.ActiveSession

Begin Dialog UserDialog 185, 52, 280, 174, "Share Aging"
   TextBox  95, 5, 51, 13, .freeshrbox
   TextBox  95, 19, 51, 13, .tfrdatebox
   TextBox  95, 32, 51, 13, .redfeedatebox
   TextBox  95, 46, 51, 13, .navpricebox
   OptionGroup.optiongroup1
      OptionButton  10, 79, 46, 10, "Purchases", .OptionButton4
      OptionButton  10, 95, 60, 10, "Purchases A+", .OptionButton1
      OptionButton  10, 110, 60, 10, "Free Side Load", .OptionButton2
      OptionButton  10, 130, 45, 10, "Dividends", .OptionButton3
      OptionButton  90, 85, 46, 10, "Purchases", .OptionButton5
      OptionButton  90, 102, 65, 10, "Free Side Load", .OptionButton6
      OptionButton  90, 119, 50, 10, "Dividends", .OptionButton7
      OptionButton  180, 80, 80, 11, "Purchases (Liable)", .OptionButton8
      OptionButton  180, 97, 95, 11, "Purchases (Not Liable)", .OptionButton9
      OptionButton  180, 114, 65, 10, "Free Side Load", .OptionButton10
      OptionButton  180, 131, 44, 10, "Dividends", .OptionButton11
   TextBox  95, 149, 53, 13, .microbox
   OkButton  170, 148, 36, 14
   CancelButton  215, 148, 36, 14
   GroupBox  5, 65, 74, 80, "A Shares"
   Text  28, 154, 54, 8, "Micro Ref # Date"
   GroupBox  85, 65, 85, 80, "B Shares"
   GroupBox  170, 65, 110, 80, "C Shares"
   Text  20, 5, 65, 10, "Adj Free Shares"
   Text  18, 21, 65, 8, "Transfer/Purch Date"
   Text  19, 49, 65, 8, "NAV Price", .navprice
   Text  20, 35, 65, 8, "Red Fee Liable Date"
   
End Dialog

Dim optsdialog as UserDialog

Dialog optsdialog

'Radio Button selection send to screen

Select case optsdialog.optiongroup1

    Case 0   '"Purchases", .OptionButton4
        sess.screen.putstring "N",1,2  'putstring "String",Row,Column
        sess.screen.putstring "Y",2,3
        sess.screen.putstring "Y",3,4
        sess.screen.putstring "C",4,5
        sess.screen.putstring "2",5,6 
        sess.screen.putstring "Y",6,7
    Case 1   '"Purchases A+", .OptionButton1
        sess.screen.putstring "Y",1,2  
        sess.screen.putstring "N",2,3
        sess.screen.putstring "N",3,4
        sess.screen.putstring "A",4,5
        sess.screen.putstring "1",5,6 
        sess.screen.putstring "N",6,7
     Case 2   '"Free Side Load", .OptionButton2
        'do stuff
       
        
     Case 3   '"Dividends", .OptionButton3
        'do stuff
             
     Case 4    '"Purchases", .OptionButton5
        'do stuff
     
     Case 5    '"Free Side Load", .OptionButton6
        'do stuff
     
     Case 6    '"Dividends", .OptionButton7
        'do stuff
     
     Case 7    '"Purchases (Liable)", .OptionButton8
        'do stuff
     
     Case 8    '"Purchases (Not Liable)", .OptionButton9
        'do stuff
     
     Case 9    '"Free Side Load", .OptionButton10
        'do stuff
   
     Case 10   '"Dividends", .OptionButton11
        'do stuff
     
     Case Else
        msgbox "Invalid Option"
     
End Select

Set Sess=nothing
Set System=nothing

End Sub
 
Hi JamesDSM50328,

That worked!!! I was able to insert your code into mine, make some minor modifications, and now it functions. I really appreciate your assistance.

I have 2 other "bugs" to deal with but I will need to post them under different titles.

Thank you again.

jamminbuddha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top