Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Data Types 1

Status
Not open for further replies.

autumn10

Technical User
Feb 21, 2011
9
US
In VBA under program control, how do I convert an integer to a character so that I can use &
 



hi,
Code:
dim MyString as string, i as integer

for i = 1 to 2
   MyString = "Number " & CInt(i)
next
or even...
Code:
dim MyString as string, i as integer

for i = 1 to 2
   MyString = "Number " & i
next
because the VBA runtime does the conversion for you. I prefer the former.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks Skip. I prefer the former as well. I'm trying to delete forms UserForm21 UserForm22 UserForm23 using the following code:

Sub Remove_Form()

Dim i As Integer
Dim s As String
For i = 21 To 23
s = "UserForm" & "i"
Application.VBE.ActiveVBProject.VBComponents.Remove Application.VBE.ActiveVBProject.VBComponents(s)
Next i
End Sub

What is the best way to make it work?
 

hi,
Code:
    Dim oVBA As Object
    
    With Application.VBE.ActiveVBProject
        For Each oVBA In .VBComponents
            If oVBA.Type = vbext_ct_msform Then _
               .VBComponents.Remove .VBComponents(oVBA.Name)
        Next
    End With

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Replace this:
s = "UserForm" & "i"
with this:
s = "UserForm" & i

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Skip -
Thanks but I just want to get rid of UserForm21, UserForm22, & UserForm23. Not all of them.
 


Code:
    Dim oVBA As Object

    With Application.VBE.ActiveVBProject
        For Each oVBA In .VBComponents
            Select Case oVBA.Name
                Case "UserForm21", "UserForm22", "UserForm23"
                    .VBComponents.Remove .VBComponents(oVBA.Name)
            End Select
        Next
    End With

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top