What is the difference between assignment and comparison in VBScript?

In summary, RahulFida wants to create a script that will allow the user to enter a number and then return the corresponding integer. If the user enters a number that is not within the expected range, RahulFida suggests that they try again.
  • #1
fida
3
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
  • #2
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
 
  • #3
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
 

1. What is a linear algorithm and how is it used in a vB program?

A linear algorithm is a step-by-step set of instructions that is used to solve a problem in a sequential manner. In a vB program, a linear algorithm is used to write code that can be executed in a linear fashion, meaning that each instruction is executed in the order it was written.

2. What is the difference between a linear algorithm and a non-linear algorithm?

A linear algorithm follows a straight path, whereas a non-linear algorithm may have multiple paths and conditions. This means that a linear algorithm will always have the same outcome for a given input, while a non-linear algorithm may have different outcomes depending on the input.

3. How do you determine the efficiency of a linear algorithm in a vB program?

The efficiency of a linear algorithm can be determined by analyzing the time and memory complexity of the code. This involves calculating the number of steps and amount of memory that the algorithm requires to solve a problem. A more efficient algorithm will have a lower time and memory complexity.

4. Can a linear algorithm be used for all types of problems in a vB program?

No, a linear algorithm may not be the most efficient or appropriate solution for all types of problems. In some cases, a non-linear algorithm may be more suitable for solving a problem. It is important to consider the specific problem and its requirements when choosing an algorithm.

5. How can you optimize a linear algorithm in a vB program?

There are several ways to optimize a linear algorithm, such as reducing the number of steps, using more efficient data structures, and avoiding unnecessary operations. Additionally, choosing the most appropriate algorithm for a specific problem can also greatly improve its efficiency.

Similar threads

  • Programming and Computer Science
Replies
2
Views
856
Replies
17
Views
2K
  • Introductory Physics Homework Help
Replies
17
Views
279
  • Introductory Physics Homework Help
Replies
29
Views
808
Replies
3
Views
2K
  • STEM Academic Advising
Replies
13
Views
2K
  • STEM Academic Advising
Replies
9
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
4K
Back
Top