What is the difference between assignment and comparison in VBScript?

Click For Summary
SUMMARY

The forum discussion clarifies the distinction between assignment and comparison in VBScript. In VBScript, the statement "x = y" can serve as both an assignment, where the value of y is assigned to x, and as a comparison, which evaluates whether x and y are equal. The Eval method interprets this as a comparison, while the Execute statement treats it as an assignment. This duality does not exist in Microsoft JScript, where different operators are used for assignment and comparison.

PREREQUISITES
  • Understanding of VBScript syntax and semantics
  • Familiarity with the Eval and Execute statements in VBScript
  • Basic knowledge of conditional statements and loops in programming
  • Experience with optimization problems in programming
NEXT STEPS
  • Explore the use of the Eval function in VBScript for dynamic expression evaluation
  • Learn about the differences between assignment and comparison in other programming languages
  • Research optimization algorithms for linear programming
  • Study the implementation of graphical representations of equations in VBScript
USEFUL FOR

VBScript developers, programmers working on optimization problems, and anyone interested in understanding the nuances of variable assignment and comparison in scripting languages.

fida
Messages
3
Reaction score
0
hello,
i want to make a linear program which has such this conditional:
if the inputs have 2 variables (ex. x & y) and make equations (ex. 2x + 3y <= 23, 5x + y <= 12) then both equation will shown in graphic.
but if the inputs have more than 2 variables (ex. x, y & z) and have some equations then the solution shown in table.
both programs are optimization case (minimization or maximization).
can anyone help me in making the source codes in vb and/or the algorithms? i really need it, pls! if u have the info feel free to send me an email to fida_nich@hotmail.com
tq
 
Technology news on Phys.org
Hi
This is very tedious job to solve the equation in the generic programming language
So please use the vb script embedded in the visual basic program to solve the equation

Systax :

[result = ]Eval(expression)
Arguments result Optional. Variable to which return value assignment is made. If result is not specified, consider using the Execute statement instead.
expression Required. String containing any legal VBScript expression.


Regards,
Rahul
 
Fida

In VBScript, x = y can be interpreted two ways. The first is as an assignment statement, where the value of y is assigned to x. The second interpretation is as an expression that tests if x and y have the same value. If they do, result is True; if they are not, result is False. The Eval method always uses the second interpretation, whereas the Execute statement always uses the first.

Note In Microsoft® JScript™, no confusion exists between assignment and comparison, because the assignment operator (=) is different from the comparison operator (==).
The following example illustrates the use of the Eval function:

Sub GuessANumber
Dim Guess, RndNum
RndNum = Int((100) * Rnd(1) + 1)
Guess = CInt(InputBox("Enter your guess:",,0))
Do
If Eval("Guess = RndNum") Then
MsgBox "Congratulations! You guessed it!"
Exit Sub
Else
Guess = CInt(InputBox("Sorry! Try again.",,0))
End If
Loop Until Guess = 0
End Sub
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
3K
Replies
3
Views
3K
  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 9 ·
Replies
9
Views
4K
Replies
17
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 29 ·
Replies
29
Views
4K
Replies
12
Views
7K