DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

integer in a textbox

Solved!
Go to solution

Hello,

 

I am using Diadem 2012, and i have a problem to acquire a number in a textbox.

Im new in Diadem and programming so please excuse me if my questions seems basics 😄

 

My textbox is configured like this:

Variable: tolerance

VariableColIndex 1

VariableRowIndex 1

 

In Edit/Variables i have selected:

type: Integer

Storage mode: Scalar

 

I got an error message when i launch the dialog box :

Cannot link variables(s) to the dialog box:

tolerance: You have specified this variable with an invalid type. This is the right type: Variant

 

I suppose i should be able to put an integer here?

 

--------------------------------

In the case i use the variant type

 

I define in the script: GlobalDim("tolerance")

 

But when i write a number it return me "5" (the text i suppose) and not the number 5.

 

What should i do?

 

 

Also is there an other way of using data beteen dialogbox and script than using GlobalDim in the script and define the variable manualy in the dialogbox?

 

Best regards,

 

Frédéric

 

0 Kudos
Message 1 of 6
(5,113 Views)

I find how to convert variant integer in the script

tolerance = CInt(tolerance)

 

And for the rest do somebody have a solution?

0 Kudos
Message 2 of 6
(5,102 Views)

Hi Frederic,

 

I don't know what you mean about defining the variable manually in the dialog box.  The GlobalDim command in the VBScript that calls the SUDialog actually defines the variable.  You can use the variable in the dialog box, but you must define/declare the variable before you call the dialog box.

 

How are you noticing the difference between "5" and 5 in the dialog box?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 6
(5,091 Views)

hello,

 

It is define like this in the script

Call GlobalDim("tolerance")

Call SUDDlgShow("Dlg1",MyFolders(1)&"dialogbox.SUD",NULL)

 

By "define the variable manualy" I mean i have to define it in Edit/variables in the Dialog editor. And i can only use "variant"

 

When i run the script and i check my value (the tool under the script where you can add value to look at) i see "5"

 

After i did this :

tolerance = CInt(tolerance)

I see tolerance = 5

 

I would like to see this value as an integer from the beginning, without converting it after

 

Fred

 

0 Kudos
Message 4 of 6
(5,076 Views)
Solution
Accepted by topic author fmanuel

Hi Fred,

 

I'm sorry, the text box in SUDialogs always returns a string, so you will need to use the CLng() command in the SUDialog to convert the value of the "Tolerance" variable from a variant of subtype string to a variant of subtype integer.  You could do that in the LoseFocus event of the text box or the Terminate event of the SUDialog.

 

Alternatively, you could declare an explicitly data typed variable with OdsValAlloc() or by loading a *.vas file with UserVarCompile(), then you could associate an integer variable instead of a variant variable with the text box, and the SUDialog would automatically coerce the string returned by the text box to an integer.  In this case the SUDialog would also pop up an error dialog that you can not control if the user enters a non-integer value into the text box.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 6
(5,069 Views)

ok, thanks for information 😉

0 Kudos
Message 6 of 6
(5,052 Views)