jamminbuddha
Technical User
I have a functioning program that repeats the dialog box halfway through the instructions. I know it is declared twice so that is why it pops up again in order to get the rest of the user input. The second declaration is within a nested Select Case structure. Anyway I edit the code to prevent this, the nested case that controls my option buttons for my dialog box only reads the first case option regardless of what the user selects.
I am thinking that declaring a function "(Function FileDlgFunction(identifier$, action, suppvalue)"
may be the solution, but I am not so sure how to accomplish this. Please assist. Thanks!
See my code below:
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
rem 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 141, 52, 294, 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 11, 80, 46, 10, "Purchases", .OptionButton1
OptionButton 10, 95, 60, 10, "Purchases A+", .OptionButton2
OptionButton 10, 110, 60, 10, "Free Side Load", .OptionButton3
OptionButton 10, 130, 45, 10, "Dividends", .OptionButton4
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, 155, 53, 13, .microbox
OkButton 170, 155, 36, 14
CancelButton 215, 155, 36, 14
GroupBox 5, 65, 74, 80, "A Shares"
Text 28, 156, 54, 8, "Micro Ref # Date"
GroupBox 85, 65, 85, 80, "B Shares"
GroupBox 175, 65, 110, 80, "C Shares"
Text 20, 5, 65, 10, "Adj Free Shares"
Text 19, 19, 65, 8, "Transfer Date"
Text 20, 50, 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.
Dim optsdialog as UserDialog
Dialog optsdialog
'Radio Button selection send to screen
Select case optsdialog.optiongroup1
Case 0 '"Purchases", .OptionButton4
myscreen.putstring "N",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 1 '"Purchases A+", .OptionButton1
myscreen.putstring "Y",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 2 '"Free Side Load", .OptionButton2
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "3",17,52
myscreen.putstring "Y",17,68
Case 3 '"Dividends", .OptionButton3
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "N",9,68
myscreen.putstring "D",17,48
myscreen.putstring "1",17,52
myscreen.putstring "N",17,68
Case 4 '"Purchases", .OptionButton5
myscreen.putstring "Y",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 5 '"Free Side Load", .OptionButton6
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "3",17,52
myscreen.putstring "Y",17,68
Case 6 '"Dividends", .OptionButton7
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "N",9,68
myscreen.putstring "D",17,48
myscreen.putstring "1",17,52
myscreen.putstring "N",17,68
Case 7 '"Purchases (Liable)", .OptionButton8
myscreen.putstring "Y",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 8 '"Purchases (Not Liable)", .OptionButton9
myscreen.putstring "N",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 9 '"Free Side Load", .OptionButton10
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "3",17,52
myscreen.putstring "Y",17,68
Case 10 '"Dividends", .OptionButton11
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "N",9,68
myscreen.putstring "D",17,48
myscreen.putstring "1",17,52
myscreen.putstring "N",17,68
Case Else
msgbox "Invalid Option"
End Select
Set Sess=nothing
Set System=nothing
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
I am thinking that declaring a function "(Function FileDlgFunction(identifier$, action, suppvalue)"
may be the solution, but I am not so sure how to accomplish this. Please assist. Thanks!
See my code below:
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
rem 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 141, 52, 294, 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 11, 80, 46, 10, "Purchases", .OptionButton1
OptionButton 10, 95, 60, 10, "Purchases A+", .OptionButton2
OptionButton 10, 110, 60, 10, "Free Side Load", .OptionButton3
OptionButton 10, 130, 45, 10, "Dividends", .OptionButton4
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, 155, 53, 13, .microbox
OkButton 170, 155, 36, 14
CancelButton 215, 155, 36, 14
GroupBox 5, 65, 74, 80, "A Shares"
Text 28, 156, 54, 8, "Micro Ref # Date"
GroupBox 85, 65, 85, 80, "B Shares"
GroupBox 175, 65, 110, 80, "C Shares"
Text 20, 5, 65, 10, "Adj Free Shares"
Text 19, 19, 65, 8, "Transfer Date"
Text 20, 50, 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.
Dim optsdialog as UserDialog
Dialog optsdialog
'Radio Button selection send to screen
Select case optsdialog.optiongroup1
Case 0 '"Purchases", .OptionButton4
myscreen.putstring "N",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 1 '"Purchases A+", .OptionButton1
myscreen.putstring "Y",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 2 '"Free Side Load", .OptionButton2
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "3",17,52
myscreen.putstring "Y",17,68
Case 3 '"Dividends", .OptionButton3
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "N",9,68
myscreen.putstring "D",17,48
myscreen.putstring "1",17,52
myscreen.putstring "N",17,68
Case 4 '"Purchases", .OptionButton5
myscreen.putstring "Y",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 5 '"Free Side Load", .OptionButton6
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "3",17,52
myscreen.putstring "Y",17,68
Case 6 '"Dividends", .OptionButton7
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "N",9,68
myscreen.putstring "D",17,48
myscreen.putstring "1",17,52
myscreen.putstring "N",17,68
Case 7 '"Purchases (Liable)", .OptionButton8
myscreen.putstring "Y",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 8 '"Purchases (Not Liable)", .OptionButton9
myscreen.putstring "N",9,19
myscreen.putstring "Y",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "C",17,48
myscreen.putstring "2",17,52
myscreen.putstring "Y",17,68
Case 9 '"Free Side Load", .OptionButton10
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "Y",9,68
myscreen.putstring "3",17,52
myscreen.putstring "Y",17,68
Case 10 '"Dividends", .OptionButton11
myscreen.putstring "N",9,19
myscreen.putstring "N",9,40
myscreen.putstring "N",9,68
myscreen.putstring "D",17,48
myscreen.putstring "1",17,52
myscreen.putstring "N",17,68
Case Else
msgbox "Invalid Option"
End Select
Set Sess=nothing
Set System=nothing
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