Importing text file with form and buttons

Brian the Fish

New member
Local time
Today, 12:02
Joined
Feb 28, 2010
Messages
2
I am kind of new to VB programming and need to create a program to do the following:

"In Microsoft Access Write a program to convert "test.txt" to a tab delimited file.
All fields must be trimmed of extra spaces.
Include a form to specify the input and output and a button to run the conversion."

I found the following program that seems to do what I need but I am not sure how to create the form and buttons. Can anyone help.

Dim strInputString As String
Dim strOutputString As String
Dim varSplit As Variant
Dim intUB As Integer
Dim intCount As Integer

Open strInputFile For Input As #1
Open strOutputFile For Output As #2

Do Until EOF(1)
Line Input #1, strInputString
varSplit = Split(strInputString, "|", , vbTextCompare)
intUB = UBound(varSplit)
intCount = 0
While intCount <> intUB + 1
strOutputString = strOutputString & varSplit(intCount) & Chr(9)
intCount = intCount + 1
Wend
Print #2, strOutputString
strOutputString = ""
intUB = 0
Loop
Close #1
Close #2

End Sub
 
We do not generally do peoples homework for them, alternatively we tell them what to do. In you case you need to look at what is being imported and set up a table that will accept the incoming data.

Also you can try looking up help in importing text files in MS Access itself.
 
I found this post searching for something else but I have a question about this code.
Where in there does it do the Trimming of spaces?

I don't see a Trim() anywhere. Where would you Trim the spaces?
 
Probably because it doesn't, which was what the OP was enquiring about. If you want to Trim() you would include it in the code.
 
The OP wanted to know how to "to create the form and buttons"

I am wondering WHERE in the code would you put it?

In this line?
strOutputString = strOutputString & varSplit(intCount) & Chr(9)
 
This was what I was referring to. Not directly from the OP though ;)
.All fields must be trimmed of extra spaces.

You can trim here:

strOutputString = strOutputString & trim(varSplit(intCount)) & Chr(9)
 

Users who are viewing this thread

Back
Top Bottom