11-10-2015 12:09 PM
Hello,
I am wondering, if vbs has an option to create a message box which will show different text´s depending on the value of my variables.
I know I can create multiple message boxes which will be shown in the selected cases (for example an If-command). But I have some more variables and that would result in a lot of message boxes.
If I could choose one text for one variable depending on it´s value and then independently choose another text depending on another variables value and so on...and display all that in one message box ,that would really help me.
a small example:
I have 5 variables: a, b, c, d, e
during my script some variables value is changed
at the end there is a message box which which summaries all what happend:
for example 0 variables have been changed, the message box should say:
0 variables have been changed.
for example 1 variable has been changed, the message box should say:
variable a changed
and so on, the problem is I have a lot of variables, which would result in a huge number of message boxes
thanks in advance
11-12-2015 11:48 AM
Hi question1234,
There is no built in message box in VBScript or DIAdem that tracks the changes of variable states. You can build a display such as you describe by tracking those changes yourself. You'd need to store the initial values of all your variables at the beginning of the script and then compare the current state of all your variables at the end of your script. Please let us know if you need help with either the variable state caching, the variable state comparison, or the building of a display to show the number of changed states among your set of variables.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
11-12-2015 12:12 PM
Hello,
the main problem I face is that the text, which I want to be displayed in the message box is depending on the state of the variable. I simply don´t know how to build one display which will show a text depending on whether the variable was changed during the script or not. My problem is not the comparisson of the variables, I can do that.
the simplest way do so (but it doesn´t work) would be some if-conditions in the message box itself
example
Call MsgBoxDisp:
If variable1atthestart = variable1attheend then
"variable1 was not changed"
else
"variable1 was changed"
If variable2atthestart = variable2attheend then
"variable2 was not changed"
else
"variable2 was changed"
and so on, but you can´t write if-conditions into a msg box
and I also don´t want several message boxes showing off
hope this will help you understand my problem
kindest regards
11-13-2015 10:10 AM
Hi question1234,
How about something like this?
If variable1atthestart <> variable1attheend Then VarStr = VarStr & vbCRLF & "variable1"
If variable2atthestart <> variable2attheend Then VarStr = VarStr & vbCRLF & "variable2"
If variable3atthestart <> variable3attheend Then VarStr = VarStr & vbCRLF & "variable3"
If variable4atthestart <> variable4attheend Then VarStr = VarStr & vbCRLF & "variable4"
ChangedVariables = Split(VarStr, vbCRLF)
ChangedVarCount = UBound(ChangedVariables)
Msg = "0 variables changed"
If ChangedVarCount > 0 Then Msg = ChangedVarCount & " variables changed" & vbCRLF & String(25, "-") & VarStr
MsgBox Msg
Brad Turpin
DIAdem Product Support Engineer
National Instruments