Variable type of variable? 
Author Message
 Variable type of variable?

I am developping an ActiveX control (in VB5) that is like a TextBox control
that can only hold numbers. What I want my control to do is to  let me
forget about masking and validatting the numbers an user can enter in my
control.
The idea is that I will have a Number property that will let an get the
value of the number shown in the control. The problem is that with another
property I set the kind of number it if expected to be entered by the user
(integer, long integer, single precision, double precision, etc.). My number
property should return (and expect) the type of data specified by the other
property. The question is: How can I declare a property without specifing
its type (the AS clause)?

I don't want to use a Variant type because I don't have control over the
conversion (from variant to integer/long/single/etc.) And I know for
experience that conversion which depends on international configurations
brings me problems...

I heard that if I were programming in C what I could use is a Class
Template... but I want to do it with VB5!!

Any ideas?
Thanks!!

========================================
Pedro J. Rusjan

WEB: http://www.*-*-*.com/
========================================



Tue, 06 Jun 2000 03:00:00 GMT  
 Variable type of variable?

Quote:
> I don't want to use a Variant type because I don't have control over the
> conversion (from variant to integer/long/single/etc.)

You can convert the variant or a string to the selected type.... Anyway for
either Variant or String; see the VB conversion functions.  Brad

Quote:

>I am developping an ActiveX control (in VB5) that is like a TextBox control
>that can only hold numbers. What I want my control to do is to  let me
>forget about masking and validatting the numbers an user can enter in my
>control.
>The idea is that I will have a Number property that will let an get the
>value of the number shown in the control. The problem is that with another
>property I set the kind of number it if expected to be entered by the user
>(integer, long integer, single precision, double precision, etc.). My
number
>property should return (and expect) the type of data specified by the other
>property. The question is: How can I declare a property without specifing
>its type (the AS clause)?

>I don't want to use a Variant type because I don't have control over the
>conversion (from variant to integer/long/single/etc.) And I know for
>experience that conversion which depends on international configurations
>brings me problems...

>I heard that if I were programming in C what I could use is a Class
>Template... but I want to do it with VB5!!

>Any ideas?
>Thanks!!

>========================================
>Pedro J. Rusjan

>WEB: http://www.mug.org.ar/socios/pedro.rusjan
>========================================



Tue, 06 Jun 2000 03:00:00 GMT  
 Variable type of variable?

I think you will have to use a variant. But when the user passes you the
initial value you can work out what type has been passed to your variant.
(The VarType() function I think.)

When the user gets the value back have a Select Case construct that does the
appropriate CInt, CCur, CDbl, etc to cast your value back as the same type
through the variant.

Regards,
Simon Jones
PC Pro Magazine



Wed, 07 Jun 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. The value of a variable (String type) is the name of a variable

2. Cannot assign a variable declared as a string to a variable declared as data type

3. Largest Variable for the Long variable type

4. Type mismatch when comparing session variable to page variable

5. print variable, variable, variable etc

6. Referencing Global Variable from a variable

7. Error msg: Object variable or With block variable not set

8. Expanding a variable or referencing a field within variable

9. Obfect variable or With block variable not set

10. How do I use contents of variable as field name(db!rst!variable)

11. converting an object variable (name of a file) into a string variable

12. Object Variable With Variable Not Defined Error

 

 
Powered by phpBB® Forum Software