Below is the code I am using to retrive the name of a file, 1st.bmp and load the file name into a combo box. 1st.bmp is 7 characters long but the code in command1 tells me it is 9 charectors long.
spent hors on this but I can not see the problem, can you?
smiler44
Private Sub Form_Load()
Combo3.AddItem "Good"
End Sub
Private Sub Combo3_Click()
Dim pathname As String ' full path to find the files
Dim dir As String 'main directory
Dim subdir As String ' sub directory
dir = "C:\temp2\"
subdir = Combo3.Text ' subdir = Good
Dim strStartPath As String
pathname = dir & subdir
strStartPath = pathname
ListFolder strStartPath
End Sub
Private Sub ListFolder(sFolderPath As String)
Dim FS As New FileSystemObject
Dim FSfolder As Folder
Dim File As File
Dim i As Integer
Set FSfolder = FS.GetFolder(sFolderPath)
Text1.Text = ""
For Each File In FSfolder.Files
DoEvents
Text1.Text = File & vbCrLf ' this method gets just the file
Call forme
Next File
Set FSfolder = Nothing
End Sub
Private Sub forme()
' checks whats in text2 and if an exchange name adds it to a combo box
Dim scan As String
Dim name As String 'name is the name of exch displayed in text2
scan = Text1.Text
Text2 = Mid$(scan, 15, 16) ' scans text2 starting at 15th charector ans captures the next 16, only 7 of the 16 are charactors the rest are blank
name = Text2.Text
If Text2 <> "" Then
Combo1.AddItem name
Else
Exit Sub
End If
End Sub
Private Sub Command1_Click()
Dim text_length As Integer
text_length = Len(Combo1.Text)
Text3 = text_length
End Sub
spent hors on this but I can not see the problem, can you?
smiler44
Private Sub Form_Load()
Combo3.AddItem "Good"
End Sub
Private Sub Combo3_Click()
Dim pathname As String ' full path to find the files
Dim dir As String 'main directory
Dim subdir As String ' sub directory
dir = "C:\temp2\"
subdir = Combo3.Text ' subdir = Good
Dim strStartPath As String
pathname = dir & subdir
strStartPath = pathname
ListFolder strStartPath
End Sub
Private Sub ListFolder(sFolderPath As String)
Dim FS As New FileSystemObject
Dim FSfolder As Folder
Dim File As File
Dim i As Integer
Set FSfolder = FS.GetFolder(sFolderPath)
Text1.Text = ""
For Each File In FSfolder.Files
DoEvents
Text1.Text = File & vbCrLf ' this method gets just the file
Call forme
Next File
Set FSfolder = Nothing
End Sub
Private Sub forme()
' checks whats in text2 and if an exchange name adds it to a combo box
Dim scan As String
Dim name As String 'name is the name of exch displayed in text2
scan = Text1.Text
Text2 = Mid$(scan, 15, 16) ' scans text2 starting at 15th charector ans captures the next 16, only 7 of the 16 are charactors the rest are blank
name = Text2.Text
If Text2 <> "" Then
Combo1.AddItem name
Else
Exit Sub
End If
End Sub
Private Sub Command1_Click()
Dim text_length As Integer
text_length = Len(Combo1.Text)
Text3 = text_length
End Sub