Can't get long integer right!

09-02-2002, 12:49 AM
While I am learning Visual Basic for the first time, I'm having lots of trouble trying to solve a small problem: :mad:

I am required to develop a program:

I need to create a class to represent the very large integer of data and the typical operations/methods. It must use a character string to represent the long integer values, including to check any input given to make sure that the character array only contains characters "0 to 9" and the "+" and "-" symbol.

Then, I need to develop an application program that will test the above class by letting a user enter two long integers, and then will output the following results to the user's terminal:

+ The two individual values
+ The result of adding the two values together
+ The result of subtracting the first input from the second input
+ The result of subtracting the second input from the first input

Any help would be much appreciated!

Many Thanks!

09-02-2002, 12:58 AM
Do a search on the forum for "string math".

09-02-2002, 01:45 AM
Did a search on "string math" but seem can't to find what I am looking for to solve my problem. If you can find a particular discussion anywhere this forum, please give me a link to access the discussion

09-02-2002, 01:51 AM
I'm guessing you're a beginner that would like to experiment with the different VB functions.

Rather than trying to apply masks and filters, you should try the actual functions first.

Here's a small brief tutorial.

1) Add two textboxes, call one "txtFirstNumber" and call the other "txtSecondNumber" for example's sake.

2) Add a command button.

3) In the command button's click event, add the following code:Dim Result As Integer

Result = txtFirstNumber.Text + txtSecondNumber.Text

MsgBox "The result of " & txtFirstNumber.Text & " + " & txtSecondNumber.Text & " = " & Result
4) Run the program. Enter 5 in the first box, and 6 in the second. Press the command button, and you should get a message box saying "The result of 5 + 6 = 11.".

5) Try changing both "+"'s in the code above to either:

- for subtraction
* for multiplication or
/ for division.

09-02-2002, 02:44 AM
In the Code Library is a code example about String Math written by Squirm:

09-02-2002, 02:50 AM
To make a correction to Step 4 of Alphanumerics post:

That answer will give a messagebox saying: "The result of 5 + 6 = 56"

If you want to add the numeric values in the text boxes, do
val(txtFirstNumber.text) + val(txtSecondNumber.text)

09-02-2002, 05:12 AM
While that will work, it is not what the poster wanted. vbbisbenc is writing a string math class to deal with very large numbers, larger than an Integer could handle.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum