intialize integer to blank value? 
Author Message
 intialize integer to blank value?

How do I initialize an integer value so it displays nothing?
For example, for a string variable I can say, dim x as string, x=""
and then when x is displayed, it would be displayed as "" or no value.
How do I achieve the same result for a integer variable?
Thank you very much.


Tue, 16 Aug 2005 00:15:03 GMT  
 intialize integer to blank value?

Quote:

> How do I initialize an integer value so it displays nothing?
> For example, for a string variable I can say, dim x as string, x=""
> and then when x is displayed, it would be displayed as "" or no value.
> How do I achieve the same result for a integer variable?
> Thank you very much.

Short answer is--you can't/don't...assuming by "an integer value" you
actually mean an Integer or Long variable, not a Variant.

BTW, the statement "Dim x As String" leaves x initialized to an empty
string so your statement explicitly initializing it is unneeded and
unnecessary overhead.  Similarly, "Dim foo as Long" leaves foo = 0.

From the Help files...

Dim Statement...

"When variables are initialized, a numeric variable is initialized to 0,
a variable-length string is initialized to a zero-length string (""),
and a fixed-length string is filled with zeros. Variant variables are
initialized to Empty. Each element of a user-defined type variable is
initialized as if it were a separate variable."

General discussion on Variants....

"If you assign Null to a variable of any type other than Variant, a
trappable error occurs. Assigning Null to a Variant variable doesn't
cause an error, and Null will propagate through expressions involving
Variant variables (though Null does not propagate through certain
functions). You can return Null from any Function procedure with a
Variant return value.
Variables are not set to Null unless you explicitly assign Null to them,
so if you don't use Null in your application, you don't have to write
code that tests for and handles it."



Tue, 16 Aug 2005 01:19:47 GMT  
 intialize integer to blank value?
The variable you dimmed (Dim x As Integer) does not display it self
anywhere, it only stays in memory (value is 0 when declared.

It can ONLY be displayed through your CODE onto a CONTROL. So, it is you,
the programmer, to decide how to display, in regard to, or regardless of,
its value. Say, you use a TextBox to display x's value:

TextBox1.Text=x

If you want the TextBox to be blank when x=0

TextBox1.Text=IIF(x=0,"",x)

As long as you want, you can
If x=0 Then
    TextBox1.Text="A"
ElseIF x=1 Then
    TextBox1.Text="B"
Else
    TextBox1.Text="Whatever"

So, what value a variable holds in memory does not limit the way you display
something to user according to the value.


Quote:
> How do I initialize an integer value so it displays nothing?
> For example, for a string variable I can say, dim x as string, x=""
> and then when x is displayed, it would be displayed as "" or no value.
> How do I achieve the same result for a integer variable?
> Thank you very much.



Tue, 16 Aug 2005 02:03:57 GMT  
 intialize integer to blank value?


Wed, 18 Jun 1902 08:00:00 GMT  
 intialize integer to blank value?
THANK YOU BOTH so very much for the detailed explanations, examples
and link to help files which helped me understand the concept much
better, and especially the example on how to display a text box
control as blank is something I simply had not thought about at all --
thank you again!
================================================================
Quote:

> The variable you dimmed (Dim x As Integer) does not display it self
> anywhere, it only stays in memory (value is 0 when declared.

> It can ONLY be displayed through your CODE onto a CONTROL. So, it is you,
> the programmer, to decide how to display, in regard to, or regardless of,
> its value. Say, you use a TextBox to display x's value:

> TextBox1.Text=x

> If you want the TextBox to be blank when x=0

> TextBox1.Text=IIF(x=0,"",x)

> As long as you want, you can
> If x=0 Then
>     TextBox1.Text="A"
> ElseIF x=1 Then
>     TextBox1.Text="B"
> Else
>     TextBox1.Text="Whatever"

> So, what value a variable holds in memory does not limit the way you display
> something to user according to the value.



> > How do I initialize an integer value so it displays nothing?
> > For example, for a string variable I can say, dim x as string, x=""
> > and then when x is displayed, it would be displayed as "" or no value.
> > How do I achieve the same result for a integer variable?
> > Thank you very much.



Tue, 16 Aug 2005 23:44:06 GMT  
 intialize integer to blank value?
If <display> was really what you were/are after look at help heading:

Different Formats for Different Numeric Values (Format Function)

for a different way to accomplish the same thing...        

Quote:

> THANK YOU BOTH so very much for the detailed explanations, examples
> and link to help files which helped me understand the concept much
> better, and especially the example on how to display a text box
> control as blank is something I simply had not thought about at all --
> thank you again!
> ================================================================


> > The variable you dimmed (Dim x As Integer) does not display it self
> > anywhere, it only stays in memory (value is 0 when declared.

> > It can ONLY be displayed through your CODE onto a CONTROL. So, it is you,
> > the programmer, to decide how to display, in regard to, or regardless of,
> > its value. Say, you use a TextBox to display x's value:

> > TextBox1.Text=x

> > If you want the TextBox to be blank when x=0

> > TextBox1.Text=IIF(x=0,"",x)

> > As long as you want, you can
> > If x=0 Then
> >     TextBox1.Text="A"
> > ElseIF x=1 Then
> >     TextBox1.Text="B"
> > Else
> >     TextBox1.Text="Whatever"

> > So, what value a variable holds in memory does not limit the way you display
> > something to user according to the value.



> > > How do I initialize an integer value so it displays nothing?
> > > For example, for a string variable I can say, dim x as string, x=""
> > > and then when x is displayed, it would be displayed as "" or no value.
> > > How do I achieve the same result for a integer variable?
> > > Thank you very much.



Wed, 17 Aug 2005 00:07:28 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. restricting values of integers in code

2. Pass integer Value from forms Class mod to report class mod

3. integer values for fields

4. &H before integer value

5. Enum String Value (deriving from a Type Name and an Integer)

6. Listbox.Text to integer value

7. Help: converting long integer colour values to RGB

8. Storing multiple setting values in an Integer

9. Conversion from string value to long integer.

10. Problem : Unable to pass an integer value from Visual Basic to Fortran DLL

11. Retrieving integer value from Registry

12. Shell command return value is not an integer in VB4

 

 
Powered by phpBB® Forum Software