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!

User defined input from dialog box. 1

Status
Not open for further replies.

2010noACAPS

Technical User
Mar 29, 2004
41
0
0
US
I need help with a dialog box I'm creating. I have Extra! 6.7x, which has a dialog designer so I can generate the dialog box code fine. I have 3 issues:

1) I'm not sure how to make the PutString line look to put the user defined string on the screen I have the macro go to.

2) I want to have a drop down list of 5 items and whichever item the user chooses needs to be put in a certain field in Extra! and the Extra! help wasn't very clear of how to do that.

3) I also need the macro to take 2 numbers the user enters and subtract the two and put the total into a field on screen.

Any information would be helpful. I've never used a dialog box to run a macro, I've created macros to copy and paste a long string, and to go to certain pages and that's it. VB is still foreign to me.


Thanks,
Todd
 
Dialog boxes are pretty difficult in Extra. The main turning point for me was understanding that each object on the dialog box will be stored in a variable for your use in code.

Here's an example of 3 textboxes I use in a dialog box (the box is named Dlg):
TextBox 5, 45, 153, 12, .txtMessage
TextBox 5, 70, 56, 12, .StartDate
TextBox 100, 70, 57, 12, .EndDate

Once the box is closed, I can refer to the Dlg.txtmessage variable to gain access to whatever the user typed. It's been awhile since I used a drop down box, but the same concept will apply.

If there are values in these boxes, I could subtract them like this:
MyNum = dlg.startdate - dlg.enddate

And enter them on the screen like this:
sess0.screen.putstring MyNum, 23,2

Overall you may find that a series of Inputboxes is a lot less comlicated and leads the user through the correct decisions. They are also a lot easier to code:

FirstNumber = Inputbox ("Enter the first number")
SecondNumber = Inputbox ("Enter the Second number")
OtherOption = Inputbox ("Enter the additional Parameters")

...code goes on...

You'll find that dealing with dialog boxes in EB is very frustrating and not entirely functional. Also, before you spend too much time on this you should evaluate how many users will be running the code. Differing screen resolutions should be accounted for early in the process. In one of my first attempts at this, I got it just right only to find that my box was unreadable on some computers at different resolutions.

Good luck,
calculus
 
I think I need to use a dialog box because I have 14 values that need to be put into 15 different fields on 5 different pages. InputBoxes just seem like they may be confusing to some users.

And I'm still not clear on how to have options for the dropdown menu. But I can just make it a text field with a list below.

Thanks for your advice.
Todd
 
For that many value's you'll probably need a dialog. The better option would be to move to VBA as it can handle the larger form easier, but that assumes you know VBA.

This will produce a drop down box and store it in a variable dlg.DropListBox1:

DropListBox 32, 23, 70, 41, "ListItem1"+chr$(9)+"ListItem2"+chr$(9)+"ListItem3", .DropListBox1

Good luck,
calculus
 
Ah, the ListItem makes since, duh! Thanks.

Yeah, I don't know VBA yet. I have an O'Reilly's book on VB & VBA so I'll look in there and see if there's any examples of dialogs.

Thanks calculus.
 
OK, I got my macro to work except for:
MyNum = VO.MoPmt - VO.SecPmt

It keeps telling me it's a type mismatch. What does that mean? If I put double quoates around the VOs, the whole line gets put on screen.
 
It means that you are trying to subtract 2 text fields.
Try this instead.

'This will convert each entry to a number before doing the math
MyNum = Val(VO.MoPmt) - Val(VO.SecPmt)

You may need to go back to a string to send it to the system:
MyNum$ = Trim(Str(MyNum))

calculus
 
calculus,

That worked great! Thanks for all your help.

Todd
 
I forgot about my Cancel...

When I push the Cancel button it tells me:
Command failed
Line number: 128
Stopping macro playback.

Line 128 is "Dialog VO", where I open my dialog box. How do I tell the macro to clear the variables and stop the macro playback?
 
I found this in help, and I think it fixed my problem.

On Error GoTo Debugger

Dialog VO

.....

done:
Exit Sub

Debugger:
msgtext="Exiting Macro" 'changed from error #...
'occrured on blah line.
MsgBox msgtext
Resume done
End Sub
 
That will work. You could also store the info in the cancel button. Then after code execution check to see if the cancel button was pressed. This may work differently on your version than what I used long ago.

calculus
 
I'm not sure what you mean. Store what in the cancel button?
 
This code is pretty ugly (not mine) but it shows how to do this:

...
Button 2, 60, 54, 14, "&Switch Flag"
Text 2, 50, 100, 10, "Do you want to switch the flag?"

Button 150, 60, 54, 14, "&Delete Sub"
Text 150, 50, 100, 10, "Do you want to delete the sub?"
End Dialog

Dim Dlg As frmInfo
Test = Dialog(dlg)


If Test = 1 or Test = 2 then

Test will =1 if the "Switch Flag" button is pressed and =2 if the "Delete Sub" button is pressed.

This allows you to "capture" which button is pressed in the box.

calculus
 
HELP!

When I step through the code it works perfectly, but when I run it it totally skips my If...Then statements. How is that possible? Here is part of my code since it's 5 pages worth all together. Please, help I do not understand how it can skip the If....Then's.

Code:
DIM VO as dlgVer

'Verify PITI is yes
Sess0.Screen.SendKeys("<Pf17>")
Pver = Sess0.Screen.GetString(8,71,1)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)


'Verify PF#
Sess0.Screen.SendKeys("<Pf5>")
PF$ = Sess0.Screen.GetString(3,61,1)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

If Pver = "Y" Then
    GoTo Verified
   Resume Next
End If


On Error GoTo Debugger


MyNum = Val(VO.MoPmt)+Val(VO.hazIns)+Val(VO.reTax)
PITI$ = "y"


If PF$ = "F" Then
    GoTo PREFILL
    ElseIf PF$ = "U" Then
    GoTo USEREXIT
    ElseIf PF$ = "_" Then
    GoTo USEREXIT
End If


USEREXIT:
 
I don't understand the code entirely, but sometimes you just need to restart if the EB editor craps out on you. Try restarting the computer and see if the same thing happens.

Remember that you've now added an OnError statement. On any error your code will now jump directly there. A useful peice of code is a msgbox on unhandled errors there that will let you know what the error was (and that there was an error).

Give this a try as the first line in the error handler:
msgbox Err & Space(5) & Error$

calculus
 
Well, it's not the editor that's crapping out. When I'm in the editor the macro works fine, it's when I run the macro through Extra! that the If...Then statements get skipped over and the macro just goes to the screens I tell it to at the beginning and then goes to "USEREXIT" where I tell it to do other stuff.

It's almost like my If...Then statements have been remarked out. The macro totally ignores them when running in Extra.

I hope that clarifies.
T
 
See the previous post about the errorhandler. Don't you tell the code to jump to UserExit on an error?

I've had a similar situation a time or two when I first started working with EB. They always turned out to be working exactly as written in the code. You'll have to diagnose your code and figure out why it's doing what you're seeing.

calculus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top