Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: tmead on February 25, 2011, 12:11:14 PM
-
I'm struggling a bit to try to get some code to update a userlabel. Seems there are a few ways of doing this. So far I've found:
Method 1
Qty = GetUserLabel(61)
Qty = Question("Enter Quantity of Line " & ThisPriority)
SetUserLabel(61,Qty)
But there is no way to pick up the current value of the label to use as a default - means the user has to type new every time
Method 2
Begin Dialog TextBoxSample 16,30,180,96,"Enter Required Quantity"
OKButton 132,20,40,14
CancelButton 132,44,40,14
Text 8,8,32,8,"Text Box:"
TextBox 8,20,100,12,.TextBox1
End Dialog
Dim Dlg1 As TextBoxSample
Button = Dialog ( Dlg1 )
SetUserLabel ( 61,Dlg1.TextBox1 )
Same problem - I can't figure a way to show the current value, and the user has to click into the field before entering data
Method 3
Default = GetUserlabel(61)
Answer = InputBox$("Enter data", "Title", Default, 200, 200)
SetUserLabel(61,Answer)
Now this one I like - but i can't crack the last bit - how to not update anything when cancel is pressed ! At the moment the contents of the label are wiped if cancel is pressed, and I'd liek them to be left alone !
The Cypress Enable manual is full of detail about how to construct dialogs, but there is a level of assumed knowledge about what to do with the output that I simply don't have !
Tim
-
Blatant bump for the post !
Does anyone know how to determine which button was pressed in a dialog box ?
Tim
-
Nt sure why the first one doesn't work, but what about this?
Default = GetUserlabel(61)
Answer = InputBox$("Enter data", "Title", Default, 200, 200)
If Answer <> "" then SetUserLabel(61,Answer)
-
Thanks for that, I've just got to a similar result by discriminating between entered data and cancel by using len(answer)>0.
I can't helpfeeling there must be a way of checking which button was pressed, which may be more elegant. However, these ways work !
Help much appreciated.
Tim
-
Tim
Begin Dialog TextBoxSample 16,30,180,96,"Enter Required Quantity"
OKButton 132,20,40,14
CancelButton 132,44,40,14
Text 8,8,32,8,"Text Box:"
TextBox 8,20,100,12,.TextBox1
End Dialog
Dim Dlg1 As TextBoxSample
Dlg1.TextBox1="Hello world" 'default value
Button = Dialog ( Dlg1 ) '-1 = ok, 0 = cancel
Ian
-
Ahh... thanks for that, I'd had a play with something similar, but did not get the syntax right.
I'm still in favour of the inputbox method, as I cannot get the DlgFocus command to allow direct entry into the box without having to click into it. The inputbox command does it for me !
Tim