Message 1 of 13
Strings won't concatenate

Not applicable
06-11-2001
04:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is driving me nuts. I have two string variables. I can display them
in message boxes individually, but when I try to concatenate them, I get
only the first string. I have jumped through all kinds of hoops trying to
figure out why, and I'm stumped. I thought maybe someone here had seen this
before.
Here is my code. I have noted the problem area.
Option Explicit
Option Compare Text
Sub UnBloat()
Dim files As Variant
Dim ComDlg As CommonDialog
Set ComDlg = New CommonDialog
With ComDlg
.DialogTitle = "Select files: "
.DefaultExt = "dvb"
.Filter = "VBA Projects|*.dvb"
.Flags = OFN_EXPLORER Or OFN_ALLOWMULTISELECT Or OFN_HIDEREADONLY
.InitDir = "T:\Acad2000\VBA"
If .ShowOpen Then
files = .ParseFileNames
Else
GoTo NoFilesSelected
End If
End With
Dim objIDE As Object
Dim i As Integer
Dim strFileName As String
Dim strBuildFile As String
Dim ProjLoaded
Dim objProj As Variant
Dim objFileSys As Object
Dim strFldrName As String
Dim objComp As Variant
Dim objRef As Variant
Set objIDE = Application.VBE
For i = LBound(files) To UBound(files)
strFileName = files(i)
ProjLoaded = False
For Each objProj In objIDE.vbprojects
strBuildFile = StrConv(objProj.buildfilename, vbUpperCase)
strBuildFile = Replace(strBuildFile, "\\FILESERVER\PROJECTS",
"T:")
strBuildFile = Replace(strBuildFile, "\\FILESERVER\CHUCK$",
"Z:")
strBuildFile = Replace(strBuildFile, ".DLL", ".DVB")
strFileName = StrConv(strFileName, vbUpperCase)
If strBuildFile = strFileName Then
ProjLoaded = True
Exit For
End If
Next
If ProjLoaded = False Then
LoadDVB strFileName
Set objProj = objIDE.vbprojects(objIDE.vbprojects.Count)
End If
MsgBox "Project: " & objProj.Name
strFileName = files(i)
'THE FOLLOWING STRING VARIABLE APPEARS TO BE THE SOURCE OF THE PROBLEM.
'IF I SET IT TO AN EXPLICIT VALUE, IT CONCATENATES PROPERLY.
strFldrName = Replace(strFileName, ".DVB", "")
MsgBox "FileName: " & strFileName
' Set objFileSys = CreateObject("Scripting.FileSystemObject")
' objFileSys.createfolder strFldrName
For Each objComp In objProj.vbcomponents
'THE SELECT CASE STRUCTURE BELOW IS WHERE I AM TRYING TO CONCATENATE THE
STRINGS.
Select Case objComp.Type
Case 1
MsgBox "Component: " & objComp.Name
MsgBox "Export to: " & strFldrName & "\" & objComp.Name
& ".bas"
Case 2
MsgBox "Component: " & objComp.Name
MsgBox "Export to: " & strFldrName & "\" & objComp.Name
& ".cls"
Case 3
MsgBox "Component: " & objComp.Name
MsgBox "Export to: " & strFldrName & "\" & objComp.Name
& ".frm"
End Select
Next
For Each objRef In objProj.references
MsgBox "Reference: " & objRef.Name & " - " & objRef.fullpath
Next
Next i
Set objIDE = Nothing
Set objProj = Nothing
Set objFileSys = Nothing
Set objComp = Nothing
Set objRef = Nothing
NoFilesSelected:
Set ComDlg = Nothing
End Sub
Thanks in advance.
--
Chuck Gabriel
Coggin Carrara, Inc.
in message boxes individually, but when I try to concatenate them, I get
only the first string. I have jumped through all kinds of hoops trying to
figure out why, and I'm stumped. I thought maybe someone here had seen this
before.
Here is my code. I have noted the problem area.
Option Explicit
Option Compare Text
Sub UnBloat()
Dim files As Variant
Dim ComDlg As CommonDialog
Set ComDlg = New CommonDialog
With ComDlg
.DialogTitle = "Select files: "
.DefaultExt = "dvb"
.Filter = "VBA Projects|*.dvb"
.Flags = OFN_EXPLORER Or OFN_ALLOWMULTISELECT Or OFN_HIDEREADONLY
.InitDir = "T:\Acad2000\VBA"
If .ShowOpen Then
files = .ParseFileNames
Else
GoTo NoFilesSelected
End If
End With
Dim objIDE As Object
Dim i As Integer
Dim strFileName As String
Dim strBuildFile As String
Dim ProjLoaded
Dim objProj As Variant
Dim objFileSys As Object
Dim strFldrName As String
Dim objComp As Variant
Dim objRef As Variant
Set objIDE = Application.VBE
For i = LBound(files) To UBound(files)
strFileName = files(i)
ProjLoaded = False
For Each objProj In objIDE.vbprojects
strBuildFile = StrConv(objProj.buildfilename, vbUpperCase)
strBuildFile = Replace(strBuildFile, "\\FILESERVER\PROJECTS",
"T:")
strBuildFile = Replace(strBuildFile, "\\FILESERVER\CHUCK$",
"Z:")
strBuildFile = Replace(strBuildFile, ".DLL", ".DVB")
strFileName = StrConv(strFileName, vbUpperCase)
If strBuildFile = strFileName Then
ProjLoaded = True
Exit For
End If
Next
If ProjLoaded = False Then
LoadDVB strFileName
Set objProj = objIDE.vbprojects(objIDE.vbprojects.Count)
End If
MsgBox "Project: " & objProj.Name
strFileName = files(i)
'THE FOLLOWING STRING VARIABLE APPEARS TO BE THE SOURCE OF THE PROBLEM.
'IF I SET IT TO AN EXPLICIT VALUE, IT CONCATENATES PROPERLY.
strFldrName = Replace(strFileName, ".DVB", "")
MsgBox "FileName: " & strFileName
' Set objFileSys = CreateObject("Scripting.FileSystemObject")
' objFileSys.createfolder strFldrName
For Each objComp In objProj.vbcomponents
'THE SELECT CASE STRUCTURE BELOW IS WHERE I AM TRYING TO CONCATENATE THE
STRINGS.
Select Case objComp.Type
Case 1
MsgBox "Component: " & objComp.Name
MsgBox "Export to: " & strFldrName & "\" & objComp.Name
& ".bas"
Case 2
MsgBox "Component: " & objComp.Name
MsgBox "Export to: " & strFldrName & "\" & objComp.Name
& ".cls"
Case 3
MsgBox "Component: " & objComp.Name
MsgBox "Export to: " & strFldrName & "\" & objComp.Name
& ".frm"
End Select
Next
For Each objRef In objProj.references
MsgBox "Reference: " & objRef.Name & " - " & objRef.fullpath
Next
Next i
Set objIDE = Nothing
Set objProj = Nothing
Set objFileSys = Nothing
Set objComp = Nothing
Set objRef = Nothing
NoFilesSelected:
Set ComDlg = Nothing
End Sub
Thanks in advance.
--
Chuck Gabriel
Coggin Carrara, Inc.