Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
change variable type
what is the vba function that is like the vb Ctype?
i have a bunch of checkboxes that get created programatically with names based on an array. i need to test these values so i have a variabled dimmed as checkbox and i need to set this based on the names in the array. thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
change variable type
There isn't a generic CType function. Most primitive data types have
functions to convert a value to that type. E.g., Dim L As Long Dim J as integer J=1234 L=CLng(J) The most common is the CStr function to convert a numeric primitive to a string: Dim S As String Dim L As Long L = 123 S = CStr(L) You can't convert arbitrarily from one type to another. You code roll your own, but that would be a lot of work that may or may not really be necessary. If your checkbox objects were created from the Controls command bar, you can use something like Dim OleObj As OLEObject For Each OleObj In Worksheets(1).OLEObjects If TypeOf OleObj.Object Is MSForms.CheckBox Then Debug.Print OleObj.Object.Caption End If Next OleObj The TypeOf/Is construct can be used with any object. E.g., Dim C1 As Object Set C1 = New Class1 If TypeOf C1 Is Class1 Then ' C1 is type Class1 Else ' C1 is not type Class1 End if Cordially, Chip Pearson Microsoft MVP Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Wed, 24 Dec 2008 07:13:20 -0800 (PST), wrote: what is the vba function that is like the vb Ctype? i have a bunch of checkboxes that get created programatically with names based on an array. i need to test these values so i have a variabled dimmed as checkbox and i need to set this based on the names in the array. thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Type change in a declared Variable? | Excel Programming | |||
Type change in a declared Variable? | Excel Programming | |||
Type change in a declared Variable? | Excel Programming | |||
Type change in a declared Variable? | Excel Programming | |||
how to change all the words of one type(Gunsuh type)to another | Excel Discussion (Misc queries) |