Quote Originally Posted by snb View Post
What's the point ?
The result of an Inputbox is always a string.
The point was curiosity.

A better way to state your second statement: the result of an Inputbox defaults to a string, no? After all, I can define S1 as an Integer and the result of S1 = InputBox("Enter first integer number:") would be an integer.

Thank you, Alan, for the explanation and example of the dangers of Variant type. I'm curious about the resources issue: does VBA use a larger chunk of memory for the variant, then revert to the lesser amount of memory after the variable is assigned a value and VBA "guesses" the type? For example,

Dim n {n is variant and uses x amount of memory}
n= 3 {VBA says that n is type variant/integer: does the memory used go down?}

Just for the sake of conversation, this works in C++:

Code:
//test stacked variables

#include<iostream>

using namespace std;

int main()
{
	long S3, S1, S2;

	cout << "Enter first integer number: ";
	cin >> S1;
	cout << "\nEnter second integer number: ";
	cin >> S2;
	S3 = S1 + S2;
	cout << "\nSum is: " << S3<<endl;

	return 0;
}
S1, S2 & S3 are all Long. So this concept in VBA is a bit of different thinking for me.

Regards,

CJ