English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have several text boxes named txtApp1dir, txtApp2dir, and so on. when this code runs it needs to check weather the path to an exe exists. fFile always comes up as false, even if the path in the text box is correct.
thanks


Dim sFileName As String
Dim X As Integer

For X = 1 To 3
sFileName = "txtApp" & X & "Dir.text"
Dim fFile As New FileInfo(sFileName)
If Not fFile.Exists Then
MessageBox.Show("Please check the directory of Application " & X)

End If
Next

2007-01-10 06:39:34 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

sFileName = "txtApp" & X & "Dir.text"
is not working it is comming out as txtApp1Dir.text. not as the text value of the text box txtApp1Dir.

2007-01-10 07:29:20 · update #1

3 answers

OK in that case it's viewing the concatenated txtApp as a string instead of as a control, so scrap that idea.

I'm not sure how many directories you want to test or why they need individual textboxes. Could you put them all into a list?

Then you could scroll through the list items one by one in a FOR loop to run through your fFile function

2007-01-10 06:55:38 · answer #1 · answered by rod 6 · 0 0

Here's your problem

You are trying to store in the sFileName variable, the text in your textboxes.

sFileName = "txtApp" & X & "Dir.text"

The code above Won't do it. here in sfilename you are storing
txtApp1Dir.text not the text in txtApp1Dir text box

basically the way You're doing it now it won't work if you change the code as I say it may Work:

Modify This Line: sFileName = "txtApp" & X & "Dir.text"

and change it for:

Select Case X
Case 1
sFileName = txtApp1Dir.Text
Case 2
sFileName = txtApp2Dir.Text
Case 3
sFileName = txtApp3Dir.Text
End Select

That may Do.

Regards.

2007-01-13 07:53:34 · answer #2 · answered by Kool_Joss 2 · 0 0

You mis-understand what 'New FileInfo(sFileName)' will do. It will create a new FileInfo object for the file whose path is inside the 'sFileName' variable. You are expecting the code will create a new FileInfo object for the file whose path is in the 'Text' property of the textbox control whose name is inside the 'sFileName' variable.

2007-01-10 07:58:42 · answer #3 · answered by ultimatebaseclass 3 · 0 0

fedest.com, questions and answers