Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Cannot Retrieve Values From A Multiple Line, Pipe Delimited Text File


Hi there,

I am trying to read a pipe delimited file, and then output to a blank document the 'nth' value (e.g. 1st & 4th, as I only want those values) for multiple rows in a file, namely "onlbgl1.sec", stored @ "c: emp".

The file has a header row (row #1), and then subsequent corresponding rows of data.

For each row of data I want to retrieve the 1st & 4th field/values, but I'm currently retrieving 'nothing' - see MsgBox results:


Code:


Dim npath As String
Dim inpstring As String
Dim spipe_loc As Integer
Dim epipe_loc As Integer
Dim onlbgl1(1 To 35) As String
Dim i As Integer

spipe_loc = 1
npath = "c: emp"
'get variables
Open npath & "onlbgl1.sec" For Input As #1
Line Input #1, inpstring
'need second line of data
Line Input #1, inpstring

For i = 1 To 32
If epipe_loc = 0 Then epipe_loc = Len(inpstring) + 1
If spipe_loc > epipe_loc Then spipe_loc = epipe_loc
onlbgl1(i) = Mid(inpstring, spipe_loc, epipe_loc - spipe_loc)
spipe_loc = epipe_loc + 1
'Debug.Print onlbgl1(i); i
Next i
' MsgBox (inpstring)
Close #1

MsgBox (onlbgl1(1))
MsgBox (onlbgl1(4))

Selection.TypeText onlbgl1(1)
Selection.TypeText onlbgl1(4)



Any help would be greatfully appreciated.

Thanks,
Andy




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Extracting/Parsing Pipe Delimited Text File?
I have these lines of text delimited by the | (pipe) symbol which read:

Muffler Bolt [abc]=|0.00|0.00|0.25|0.75
idText1|pc1|pc2|pc3|pc4

The numbers between the || may be from 0.01 - 250.00

now what I need to do is pc3*0.3=pc1 pc4*0.3=pc2

Then reassemble the line as such
idText1 & pc1 & "," & pc2 & "," & pc3 & "," & pc4

which will make the following with fixed numbers with 2 after the decimal:

Muffler Bolt [abc]=0.08,0.25,0.25,0.75

Any Help greatly appreciated.

Problems Using ADO To Retrieve Data From A Comma Delimited Text File
Hello, I am having trouble with some code and I was hoping someone could help me out. I am writing an excel macro that uses ADO to connect to a comma delimited text file and retrive data. The following are the problems I am having:

1. I have no headers in my text file, but it is being treated as if it had a header row when I fill my record set ( it automatically starts on row 2) how do I get it to look at row1 first?

2. I am using "MoveNext" to move through the recordset one record at a time. when I create a small test textfile this code works fine, but an interesting problem is occurring on a larger text file i am testing: MoveNext is skipping every other row. Why would it do this?

The following is my code:

Function Import(Symbol As String)
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim strSQL As String
    cn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=c:;Extensions=asc,csv,tab,txt;"
    strSQL = "SELECT * FROM Pwr3Lnk671gnA55.txt"
    rs.Open strSQL, cn
    Do Until rs.EOF
          If rs.Fields(11) = Symbol Then
            Import = rs.Fields(2)
            Exit Do
          End If
            rs.MoveNext
    Loop
If Import = "" Then
Import = "NA"
End If
End Function

Sub test()
Debug.Print Import("AETUF")
End Sub

 
I have attached the large text file that I am having problems with.

Thanks for any help you can provide.

Dudeman

Reading A Tab Delimited Text File Line By Line Into An Array
I have a tab delimited file created by an outside source.
I am using the below code to read it's contents into an array.

Function openFile()
Dim FileNum As Integer
Dim TotalFile As String

FileNum = FreeFile
' Reads the entire file into memory all at once
Open "c:DBUpdaterpgstd.txt" For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum
TotalFile = Replace(TotalFile, vbNewLine, vbTab)
Fields = Split(TotalFile, vbTab)

'For X = 1 To UBound(Fields) Step 1
' Now the array can be used in the mdb comparing
'Debug.Print Fields(X)
'Next

End Function

My issue is that I am trying to read the array in lots of 15 as the text file has 15 columns of data.

Some of the lines only have 4 columns of data, this is throwing out my retrieval process.

Here is a sample of the text file. (copy and paste into a text file read it correctly)

seq_idlevel_idproduct_iddescription_line1description_line2description_line3description_line4supplier_idupc_apndiscount_percentbuy_price_exbuy_price_incrrp_exrrp_incGST_percent
10P1Computer Systems
20P2Workstations
30V1HEWLETT-PACKARD
40ZCOB9939XW6200 DUAL 3.2GHZ, 1GB, 40GB SATANO INTEGRATED GRAPHICSPO_3371793900.004290.0010.0
50ZCOD2329T5710 800MHZ 256/256 XPE THIN CLNTMicrosoft Windows XP Embedded; MS IE 6.0Transmeta Crusoe 800 MHz ; PC540A13.12671.38738.52772.73850.0010.0
6

Line two only has 5 tabs then the next line starts, this obviously throws out my reading of fields.

However this file can be imported into Access and all columns are correct, so I know it can be done, just not with my limited VB knowledge.

please Help,

David

Export ADOX Recordsets From Multiple Tables To Delimited Text File
I am using VB6 with a JET (Access) database with ADOX
I have a DataGrid and a combobox that I can use to switch between tables already coded using ADOX.
How can I export the recordsets from multiply tables in the same database to one delimited text file?

I have found examples for recordsets in the same table using VB6 or VB.NET but not VB6 and mulitple tables.

Please help



Edited by - scat2 on 5/14/2005 3:00:07 PM

Retrieve 1st Line From Text File
Dear All,

I have a text file that I'm importing to excel, The first row of the file contains a name that i want to appear in a rows in column A.
The first column in the file also contains other data that should be in column2.

I know that the very first row of the file will always contain this name therefore is their a way I can just get reference the first row to retrieve this name - store it as a variable and then populate Column A with this name.

Thanks

Robin

How Can I Retrieve The 6'th Line Of A Text File?
hello,

how can I retrieve the 6'th line of a text file?

thanks

XML To Pipe Delimited OR .tab In VB
How can import a xml file & export into a Pipe Delimited
or .tab file in VB? Having a hard time finding any documentation on this...
any help is greatly appreciated......
thanks...

Retrieve <select Multiple> Values In ASPs
hi, how do i retrieve the values from a <select multiple> tag from a form in ASPs???

thanks

How Can I Retrieve Cell Values From Multiple Excel Documents In A Folder
I downloaded many xls files. I want to write a macro that reads the xls files and display them in a new empty excel file. I don't want to open each file, just get the cell values within a loop. I couldn't find an example on the internet. If you know a tutorial for visual basic appliacations for excel please let me know.
Thanks.

Inputting A Delimited Line Of Text
I have an application that has to read in data from a delimited text file. Each line of text consists of 32 segments of string data delimited by a comma.

How can I assign each segment to a different part of a string array?

Pipe Text To A File???
I'm must use VB 6.0 on 9X - 2K platforms, and I'm not real strong in VB. I'm planning on reading a postscript file, manipulating it, piping the manipulated string into a new file, and finally sending this new postscript file to the printer.

I have searched through the forums and put together the following code, which I have not tested yet so it might be buggy. The question at hand is: How do I pipe it into a new text file? And also, do you think that I'm on the right track here with this code that I have pieced together from forums?


Code:
Private Sub PSEdit(sFileName As String, _
sBarcode As String, _
sToday As String)
Dim nFileNum As Integer, sText As String, _
sNextLine As String, lLineCount As Long
nFileNum = FreeFile

Open App.Path & "" & sFileName For Input As nFileNum

Do While Not EOF(nFileNum)
Line Input #nFileNum, sNextLine

' Edit the barcode and date values
sNextLine = Replace(sNextLine, "9.99999999", sBarcode, 1, 1, 1)
sNextLine = Replace(sNextLine, "99/99/9999", sToday, 1, 1, 1)
sNextLine = Trim(sNextLine)
Words = Split(sNextLine)

' I could place everything in this string called sText
' and then pipe it into a postscript, or just pipe each
' sNextLine into the postscript now
If UBound(Words) > 0 Then
sNextLine = Trim(Words(1))
If sNextLine <> "" Then
sText = sText & sNextLine & vbCrLf
End If
End If
Loop

' If I use the sText to hold the data, I would need to pipe
' it into the postscript now

Close nFileNum

End Sub
Thanks
Eric

How To Read Multiple Line Text File Into A Variable
Hi,

I just found this site tonight. I've just started learning to program with Visual Basic and I'm having a very frustrating problem that I'm hoping someone here can help me with.

This post is a bit long. Sorry about that!

This has probably been asked many times before. My question is, how can you open a multiline text file and input EVERYTHING in the text file to a string variable? Basically, the text file will just be a list and the program will have to determine what items are on that list. I know how to open and save text files, and display text files in a textbox, but for some reason I can't figure out how to input an entire text file into a variable. It will only read the first line, and seems to ignore anything below the first line. I've been hunting on Google all night to try to find out about this, but with no luck.

Here's an example similar to what I need to do:

Let's say I have a text file named "List.txt" I have a command button that will add an item that the user chooses to this list.

Now let's say that the item the user chooses could be the string variable "new_item"

So I would have a command button with this code:

new_item=InputBox("What would you like to add to the list?")

Open "List.txt" For Append As #1
Print #1, new_item
Close #1

If we put in "a new car" for example in the input box, then this would be entered into the text file "List.txt."

Then let's click the command button again and put in "a boat" into the input box. It should then append the text file to read:

a new car
a boat

So far, so good. Now, let's say I have another string variable, named items_on_list. I also have another command button that will open the text file and determine what is on the list, with predetermined results if certain things are on the list. For example:

Open "List.txt" For Input As #1
items_on_list = Input(LOF(1), 1)
Close #1

What I WANT to do is this (again, just a generic example):

If items_on_list = "a new car" Then MsgBox("A new car, eh? Better save up!")

If items_on_list = "a new car a boat" Then MsgBox("Wow! A new car and a boat!")

But the problem I'm having is that the program would only read the first line and would ignore anything else. How can I open a text file and assign EVERYTHING, a multiline list in other words, to a string variable?

What I'm actually doing is working on a sort of strategy game that simulates a railway company. I know there are already dozens of games like this, such as Railroad Tycoon, etc. but this one will simulate a small railway company that was once in my area. I have a variable that I would like to use to keep track of specifically what locations the user has built lines to. Each time the user builds a new rail line, it would have to be appended to a list. There are certain instances, such as when a map is displayed showing all the rail lines, when this list would have to be opened and read into a variable, to determine which map to display in a picture box.

Again, I'm sorry for this post being so long! As you can tell, I'm still very new to all this. But this has been a very frustrating problem. I hope someone can help. Thank you!

Chris T.
San Bernardino, California

Pipe Files In A Folder To A Text File
I have a dbase database with a bunch of data tables in a folder. I need to get all of the files in that folder that start with "EN" and end with ".DBF" into a text file. There are a few hundred, otherwise I'd do it manually. I've search the forums but haven't found what I'm looking for and my VB is a little rusty in file handling.

Anyone have a nice snippet to get me close?

EDIT: I should add that I found a FileSystemObject example that should work, but I don't remember the trick to getting the FSO to work. It keeps telling me the user-defined type "Dim FSys As FileSystemObject" is not defined.

Give Some Code For Search String In Text File But Print Second Line Values, Delimiter
i have many paragraphs in text file like this

<B>Don Man</B><BR>
,SUMIT,TORONT,PENSIL,COMDEX,PERU,BANG
office 14, street18, hangten villa, toronto.
Advisor, Engineer
Phone: +92 (51)123-8784521<BR>
Fax: +92 (51)123-8784521<BR>

it is sure that i have to print second line values with "," delimiters in all cases, but the value of text box on which i will perform search could be any string in text file, i mean the text box value could be "street18" OR "Engineer" OR "office 14"
but prin values should be like this in all cases.

SUMIT
TORONT
PENSIL
COMDEX
PERU

How To Write Data In Multiple Lines Into A Single Line In Text File.
Hey guys, I have a question to ask. In me program, I have around 8 varibles which I need to write to a file in a single line. this is the coding I have for it.


Code:
Write #BookingNo, S_Array(S_Index).S_Sessions, S_Array(S_Index).S_Date, S_Array(S_Index).S_Name = Individual_Name, S_Array(S_Index).S_Title = Event_Title, S_Array(S_Index).S_Address = Con_Address, S_Array(S_Index).S_TelNo = Con_TelNo, S_Array(S_Index).S_Fee = Fee_paid, S_Array(S_Index).S_ArayNo = Aray_No, TotalCost
So as you see, it is difficult for me to see what fields are to be written to a file. So I was thinking whether We could put the code as:


Code:
Write #BookingNo, S_Array(S_Index).S_Sessions And _
S_Array(S_Index).S_Date And _
S_Array(S_Index).S_Name = Individual_Name And _
S_Array(S_Index).S_Title = Event_Title And _
S_Array(S_Index).S_Address = Con_Address And _
S_Array(S_Index).S_TelNo = Con_TelNo And _
S_Array(S_Index).S_Fee = Fee_paid And _
S_Array(S_Index).S_ArayNo = Aray_No, TotalCost:
If you guys get me?????
It shows an error when I try to do the new way.

thanks

Darkshade

Convert Excel To Text File With Pipe Delimiter
Hi Gurus,
I want to know how can I save a Excel file with | delimiter using VB.

Now I'm able to save the Excel file to Text file but it is saving with Tab delimiter. But I want |(pipe) Instead of Tab.

Appreciate your resposne.

Best,

AM

Drawing A Line From A Delimited File Or Listbox.indexes?
Hi ALL, long time no see, and MERRY CHRISTMAS to ya as well !!!...

ISSUE 1 is placed into the General vb forum http://www.vbcity.com/forums/topic.asp?tid=138657 dealing with error handling but this project has no errors yet.

Im creating this project in VB6 to be a helpful tool for my truck driving students and I think I only have a few issues that I need more understanding on to get it working properly. The project is attached...
ISSUE 2: I really need some help on understanding looping structures. Even though I have and use For Next statements and loop code and I've spent days, and more studying them but when I try to experiment it sometimes locks up the IDE and no matter what I've tried it's not working. I have a 24 hour graph drawn onto a scaled picturebox control with a timer control drawing, (using PSet), and a variable, (np), to update(draw) a girdline across the drawn graph in quarter hour intervals np = Timer / 900 and there are 96 intervals in 24 hours. The graph displays a truck drivers daily duty status and uses a variable " yp " to hold the status values. The yp and np variables are being used like x and y values in coordinate of the graph. Please see attached image!!...(its also included within the attached project)

When a duty change becomes necessary one of the 4 cmdduty() buttons is clicked and a .dat delimited text file is appended with the Date saved as Data(0) element in the delimited .dat file, the Duty Status " yp " is saved as Data(12) element, and the Time " np " is saved as Data(13) element the last Data(element) in each line of the file.

Im trying to figure out how to can make the graph line update itself each time the project Loads to reflect any earlier duty changes in the day(24hr period). I had some temporary coding in the form_load that drew only Off Duty from midnight to form_load time but I've since commented that out and experimented with it in the below ImportFile sub and now upon the form loading the graph gridline updates from the last change of duty to form_load time but no gridline is drawn from start(midnight) to the last change of duty. Some how Im just not getting it right and this is not working as I wish. Im wanting it to draw what duty was last used from the previous day and start this day at that duty status at midnight, np=0, and draw any duty changes between then and form_load time now as well. Is there a way to index the lines read from the .dat text file then loop through the lines extracting yp, np, and update(draw) the gridline?

   [OR] Loop a ListBox.list.index with date, yp, and np data?

What Im hoping to achieve here is to find a way in code that when a list.index is selected(highlighted) with a click the code will find all the list.indexes that contain the same date as the selected(highlighted) date which comes from the .dat file and populates the listbox and then starting from the lowest list.index, with that date, icrement through the indexes and update(draw) the gridline up to the point of form_load time. Maybe a Select Case type is needed if previous dates are selected for viewing.

Also somehow the code needs to check, before updating the girdline, if the previous days last duty change(last list.index of previous day) was something other than Off Duty(yp1) and if so(true) then start todays gridline(start) with the previous days gridline(end). Usually should be Off Duty especially if driving in local situations however and especially with OTR or Over The Road situations drivers many times will drive through the night to deliver products such as PC's and everything else people use.

I have List1 populated from .dat file within the ImportFile sub:
Code:[vb]'Data(0) is Date, Data(12) is yp, Data(13) is np, and lst1.ListCount
List1.AddItem (Data(0) & "/" & Data(12) & "/" & Data(13) & "/" & lst1.ListCount)
List1.ListIndex = List1.ListCount - 1 'makes the last list entry selected(highlighted) upon form_load
As an example once the form_load is achieved List1.List looks like this:
12/21/2006/7/11/181 <---lowest List.index with the same date
12/21/2006/5/12/182
12/21/2006/7/21/183
12/21/2006/5/24/184
12/21/2006/7/33/185
12/21/2006/1/35/186 <---highest List.index with the same date
Here's the ImportFile sub Please Help, my brain is turning to mushhh...
Code:'sub found in VB forum search for string manipulation and is Called from form_load sub
Public Sub ImportFile(sfilename As String)
   Dim X As Integer, i As Integer
   Dim Lines() As String
   Dim Data() As String

   'gives the saved .dat file a number value name for each month/year
   'a new .dat file each month. I figure each file will grow to around 40kb's or less
   If frmcal1.monthv1.Day >= 1 Then
      sfilename = frmcal1.monthv1.Month & frmcal1.monthv1.Year
   End If

   'opens the .dat file and inputs it's data to the program
   Open App.Path & "Data" & sfilename & ".dat" For Input As #1
   Lines = Split(Input(LOF(1), 1), vbCrLf) '.dat file data goes to a variable called Lines

   Close #1 'closes the file

   'Now you have each line in its own element of the array Lines()
   'Loop through and split again by /
   For X = 0 To UBound(Lines)

      'The InStrB function is used with byte data contained in a string.
      'Instead of returning the character position of the first occurrence
      'of one string within another, InStrB returns the byte position.
      If InStrB(1, Lines(X), "/") Then
         Data = Split(Lines(X), "/")

         'now each part of the line is in its own element of Data()
         'fill the labels with the Data elements
         lbltotalmilestoday.Caption = Data(4)
         lbltotalmilesdriving.Caption = Data(5)
         lblcarriername.Caption = Data(6)
         lblofficeaddress.Caption = Data(7)
         lblvehiclenumbers.Caption = Data(8)
         lblcodriver.Caption = Data(9)
         lblhomeaddress.Caption = Data(10)
         lblBOL.Caption = Data(11)

         'adds ALL the month dates=Data(0), times=Data(1), going to status=Data(2),
         'and location & status details=Data(3) from .dat file into the listbox
         lst1.AddItem (Data(0) & " - " & Data(1) & " - " & "Going To:" & Data(2) & " - " _
            & Data(3))
         lst1.ListIndex = lst1.ListCount - 1 'makes the last list entry selected(highlighted)
                                                              'upon form_load.
         'need something like a loop below to find what duty status, yp, was used yesterday or
         'the last duty status previous to today. Then that status, yp, should be used to
         'start this days graph gridline at midnight, np=0. Then update the graph gridline
         'to duty changes earlier in this day as well. "HELP!!!!"
         
         yp = Data(12)
         np = Data(13)
         p = np
         Picture1.Line (p, yp)-(np, yp), vbBlack

         'only used to experiment with but might be helpful to draw the gridline
         '(visible.property will changed to False)
         List1.AddItem (Data(0) & "/" & Data(12) & "/" & Data(13) & "/" & lst1.ListCount)
         List1.ListIndex = List1.ListCount - 1 'makes the last list entry selected(highlighted)
                                                              'upon form_load.
      End If

      For i = 0 To UBound(Data)
         'not sure what I can do with this For Next statement
      Next
   Next

End Sub




Edited by - WeBad on 12/22/2006 11:47:10 AM

Retrieve The Text From An RTB Line By Line
Is it possible to set the maximum no of characters per line of an RTB? Ex. 80 chars per line.
And so , how do I retrieve the the text from a rich text box (RTB) control line by line?

VBA For Excel - How To Get A Range Of Multiple Values Across More Than One Line
Sub Copier()

Sheets.Add
Sheets("Sheet1").Select
'Sheets("Sheet1").Name = "Average"
'Range("9976:9976,9989:9989,10001:10001,10011:10011").Select


Range("61:61,122:122,183:183,244:244,305:305,366:366,427:427,488:488,5 49:549,610:610,671:671,732:732,793:793,854:854,915:915,976:976,1037:10 37,1098:1098,1159:1159,1220:1220,1281:1281,1342:1342,1403:1403,1464:14 64,1525:1525,1586:1586,,1647:1647,1708:1708,1769:1769,1830:1830,1891:1 891,,1952:1952,2013:2013,2074:2074,2135:2135,2196:2196,2257:2257,2318: 2318,2379:2379,2440:2440,2501:2501,2562:2562,2623:2623,2684:2684,2745: 2745,2806:2806,2867:2867,2928:2928,2989:2989,3050:3050,3111:3111,3172: 3172,3233:3233,3294:3294,3355:3355,3416:3416,3477:3477,3538:3538,3599: 3599,3660:3660,3721:3721,3782:3782,3843:3843,3904:3904,3965:3965,4026: 4026,4087:4087,4148:4148,4209:4209,4270:4270,4392:4392,4453:4453,4514: 4514,4575:4575,4636:4636,4697:4697,4758:4758,4819:4819,4880:4880,4941: 4941,5002:5002,5063:5063,5124:5124,5185:5185,,5246:5246,5307:5307,5368 :5368,5429:5429,5490:5490,5551:5551,5612:5612,5673:5673,5734:5734,5795 :5795,5856:5856,5917:5917" &_
",5978:5978,6039:6039,6100:6100,6161:6161,6222:6222,6283:6283,6344:634 4,6405:6405,6466:6466,6527:6527,6588:6588,6649:6649,6710:6710,6771:677 1,6832:6832,6893:6893,6954:6954,7015:7015,7076:7076,7137:7137,7198:719 8,7259:7259,7320:7320,7381:7381,7442:7442,7503:7503,7564:7564,7625:762 5,7686:7686,7747:7747,7808:7808,7869:7869,7930:7930,7991:7991,8052:805 2,8113:8113,8174:8174,8235:8235,8296:8296,8357:8357,8418:8418,8479:847 9,8540:8540,8601:8601,8662:8662,8723:8723,8784:8784,8845:8845,8906:890 6,8967:8967,9028:9028,9089:9089,9150:9150,9211:9211,9272:9272,9333:933 3,9394:9394,9455:9455,9516:9516,9577:9577,9638:9638,9699:9699,9760:976 0,9821:9821,9882:9882,9943:9943,10004:10004").Select
Selection.Copy
'Sheets("Sheet3").Select
Sheets("Average").Select
Range("A1").Select
'Sheets("Sheet1").Name = "Average"
ActiveSheet.Paste
'Range("A10011").Activate

End Sub

Loading Multiple Array Values In One Line
Thanks in advance for any help on this issue.
1st time posting on this forum.
I currently have a Visual Basic module, used in MS Excel, using VB 6.3.
The module runs a Fortran dll and returns ~200 data variables, all within a single array.
Within the VB module, a 2D array is loaded with a String Array to provide a text description that can be accessed by the users.

Curently this array is defined as:

sLabels(1,1) = "Ambient Pressure"
sLabels(1,2) = "psia"
sLabels(2,1) = " Ambient Temperature"
sLabels(2,2) = "deg F"
sLabels(3,1) = "Ambient Specific Humidity"
sLabels(3,2) = "lb water/lb dry air"
....

This format functions just fine.

I want to reconfigure it similar to:

sLabels(1,1:2) = "Ambient Pressure","psia"
sLabels(2:1:2) = "Ambient Temeprature","deg F"
sLabels(3,1:2) = "Ambient Specific Humidity","lb water/lb dry air"

This would streamline our ~200 output String Array sLabels.

However, this format does not work!

I have looked and looked and cannot find a reference in MSDN that helps.

Can anyone suggest how to input 2 array elements at a time in 1 line?

Thanks

Sending Values Multiple Values To ONE Word File[Resolved Like A Horny Ho']
I have searched for how to do this and have the code to start up a word app: (thanks to Carl)

Option Explicit

VB Code:
Private Sub Command1_Click()    Dim WordApp As Word.Application    Set WordApp = New Word.Application    With WordApp        'create word app from default template        .Documents.Add "Normal.dot"        'don't ask me to save before quiting!        .DisplayAlerts = wdAlertsNone        'show the word window        .Visible = True        'active the window        .Activate        'send text to the window        .Selection.Text = "Hello World!"        'print the page        .PrintOut        'wait for document to print before quiting        Do While WordApp.BackgroundPrintingStatus        Loop        'quit        .Quit    End With    Set WordApp = Nothing    End Sub


But what I need to do is have users check the fields who's values they want to include in a report and have the word file as the report. Here's a GIF of what I mean:

The checkboxes indicate the values and field names to be included in the word document.
Does anyone know how to do this/a tutorial for this?
thank you xxxx

Retrieve A Line After Using Open File For Input As??
Hey every one my help is not installed on the pc im using at the mo and i am just trying to remember the syntax for using lineinput with a file opened for input

if someone could post an example or the correct syntax it would be great

thanks everyone

Tab Delimited Text File
Hi,

I am not sure what is happening here. I need to create a tab delimited text file and here is what I am doing:

Dim strTextLine As String

'open file.
Open "test.txt" For Output As #1

strTextLine = "!TRNS" & Chr(9) & "TRNSID" & & Chr(9) & "TRNSTYPE"
Write #1, strTextLine

'close file.
Close #1


When I open this in Excel, the tabs were not set. All the text is in the first cell and the tabs are seen as "squares" within the text.

What am I doing wrong here?

Thanks.

Delimited Text File
I am creating a tab delimited text file and inserting the following line:

Dim TransmitID As String

TransmitID = "000002"

Print #3, TransmitID; Chr(9); " "; Chr(9); Date; Chr(9); Date

This is fine but when I import this text file into excel it removes the leading zeros of the TransmitID. Anyone any ideas?

Also I have another line:

Print #3, rstMyTable!ck_tot; Chr(9); rstMyTable!Error

The field ck_tot is a Numeric field with 2 decimal places, but when it is imported into excel it is just a whole number.


Anyone any ideas?

Delimited Text File
Hi Everyone,

I'm trying to convert a Delimited text File to Excel. The text file uses the "|" (pipe) character as the delimiter.

What I need to know is how to detect whether a text file is delimited or not ?

I would really appreciate it, If someone could illustrate an answer with some code.

Thanks..

Delimited Text File To Dbf
How can I import a delimited text file and export to a dbase file through VB.
Thanks!

Tab Delimited Text File
I am creating a tab delimited text file and inserting the following line:

Dim TransmitID As String

TransmitID = "000002"

Print #3, TransmitID; Chr(9); " "; Chr(9); Date; Chr(9); Date

This is fine but when I import this text file into excel it removes the leading zeros of the TransmitID. I know excel does not recognise it as a string but I need to have the leading zeros.

Also I have another line:

Print #3, rstMyTable!ck_tot; Chr(9); rstMyTable!Error

The field ck_tot is a Numeric field with 2 decimal places, but when it is imported into excel it is just a whole number.


Anyone any ideas?

Delimited Text File
Hey! is anybody out there know how to open a delimited text file by using the ADO object?

Thanks,
Chris.C

Tab Delimited Text File
I have several text files in different formats from which I need to pull specific data out of and export that data into an Excel spreadsheet. Please HELP! I have attached a sample of one of the text files.

Converting A Comma Delimited File To An Inline Text File For Import
I'm looking for a way to convert a text file like this:-

INVNO,DATE,AMOUNT
1,06/10/2002,100
2,07/10/2002,150
3,08/10/2002,215
4,09/10/2002,100
5,10/10/2002,654
6,11/10/2002,12

into something like this:-

INVNO
DATE
AMOUNT
#MCBG
1
06/10/2002
100
#MCBG
2
07/10/2002
150 etc

#MCBG is a separator in the package i am using.

I've only just started this and kind of know what I am doing but its going to take a lot of playing around so any help would be grateful.

Thanks
Richard

Comma Delimited Text File
Hi All

I am trying to read a comma delimited text file from vb6, and have no idea where to start, if anyone could point me in the right direction i would really appreciate it. Ultimatly i would need to strip away all the commas then write the data into an access db. I'm not asking for code justb any advise or tutorials on how to get dtarted.

Many thanks in advance

Text Delimited File Import
Ok, New Problem.

I am currently tryign to convert my access 97 Applications into "real" Applications using Visual Basic 6.0.

The Problem I am having is:

In Access we import a text delimited File in.
Inside of this file there may be 70 - 150 rows. Within Each row there is 34 fields that I need to import in to fields into a table.

So How could I do this in VB?

thanks

Reading A Tab Delimited Text File
Hi,

How can I read & get the data in to 2D array from a tab delimited text file?

Thanks,
Chamila

Help Parsing A Non-delimited Text File
I have a text file that I need to export into excel or a comma delimited file. The file consists of a solid string of prices consisting of numbers and decimal points. The only way I can think to break it down is by finding the decimal point in the string advancing 2 digits for the cents(the price is not a fixed length throughout the file) parse it and keep repeating. Also the information represents columnar data,(i.e. there are 7 fields so after each 7th price a new line should be started to build the columns required. I'm sure this is quite simple but I've been away from programming too long for it to click. Any help is appreciated!

Parsing A Delimited Text File
I am trying to capture specific parts of a text file that is delimited with the "|" symbol and in lines that begins with "FT1".
ie. FT1 |A|B|C|This part is captured|D|E|F
The information will be in that segment every time but the number of lines there are will vary.

Any ideas?

Tab Delimited Text File And Arrays
I've seen many threads that talk about tab delimited text files, but none tells me what I need to know.

I have a tab-delimited text file that holds a person's name,email address, and phone number
I need that inputed into a multi-dimension array.
Example:

VB Code:
name(0,0)="Mine"name(0,1)="example@example.com"name(0,3)="555-1212"

what would be the easiest way to do this?

Creating A Text Delimited File
I just took a visual basic course and I am writing very simple visual basic programs. One of the programs that I am writing creates a text delimited file. The problem the text is being created delimited by commas. I needed it to be delimited by spaces for example I need

"Mortgage" "234" instead of
"Mortgage","234"

How do I instruct visual basic to delimit my file with spaces instead of commas?? Thanks for your help

Help Reading In Delimited Text File?
Hi all,

I have a text file that is delimited with a pipe | . What i want to do is read in the pipe separedt values into either a dbgrid or a listview control.
ANy ideas how i can accomplish this?

Thanks for any help!
later
b

Need Some Help Parsing A Delimited Text File
I need some help getting my program to open a delimited text file and placing the information in the correct text boxes.

i have the following in the txt files
†charles
Intro to Win2k adv serv§Basic Admin course 3 days
Intro to ISA Server§Basic ISA server Install and config course

†is used to seperate users records
then comes the course on a new line
and the § seperates the course from its description

i can get it to open the entire file for editing which is useless, i need to be able to send each peice, seperated by user to a different box, ie lists the users in a text box and when you click on a user it would update the crstxtbox and update the course and description. which need to be editable seperatly but saved together.

I also have two other small things.

I need to add in a new field for each record which is a small picture which is stored in a seperate directory. and when you open the record it open the image in a picture box, and if it doesn't have a picture listed in the record it leaves it blank or loads a default picture.

and since many of these courses are the same i need the 2nd text box seperated with a drop down in which you can select the course, but not be limited to selecting a known course and be able to enter a new course

I hope this makes some sense
If some of you nice guys out there could help me with this. Also if you post code for if you have a chance could you please also post comments in it to what each part does, otherwise I am just coping and pasteing, and I would like to learn wht I am putting in so I can do it on my own next time I have a question

thanks

KC

Space Delimited Text File
I am working on a subroutine to convert space-delimited files to semicolon-delimited files. Right now the file looks something like this:

Adam Smith 45 Cherry St. 789-0098
Susan Sarandon 123 123rd Avenue 555-5555
Walter Matthau 54 Hollywood Blvd. 123-4567

Right now I am using the code

Open CommonDialog1.Filename For Input as #File1
Line Input #File1, strText

Open CommonDialog2.Filename For Output as #File2
Print #File2, Texto

Obviously all this does is copy the file but unfortunately that is about the extent of my VB experience. I need a subroutine that will read the file, replace the white spaces between columns with a ";" and also return the column length (e.g. the number of spaces between the A of Adam Smith and the first number of his phone number).

any suggestions will be GREATLY appreciated!

Thanks,

Andrew

Space Delimited Text File
I am working on a subroutine to convert space-delimited files to semicolon-delimited files. Right now the file looks something like this:

Adam Smith 45 Cherry St. 789-0098
Susan Sarandon 123 123rd Avenue 555-5555
Walter Matthau 54 Hollywood Blvd. 123-4567

Right now I am using the code

Open CommonDialog1.Filename For Input as #File1
Line Input #File1, strText

Open CommonDialog2.Filename For Output as #File2
Print #File2, Texto

Obviously all this does is copy the file but unfortunately that is about the extent of my VB experience. I need a subroutine that will read the file, replace the white spaces between columns with a ";" and also return the column length (e.g. the number of spaces between the A of Adam Smith and the first number of his phone number).

any suggestions will be GREATLY appreciated!

Thanks,

Andrew

Space Delimited Text File
I am working on a subroutine to convert space-delimited files to semicolon-delimited files. Right now the file looks something like this:

Adam Smith 45 Cherry St. 789-0098
Susan Sarandon 123 123rd Avenue 555-5555
Walter Matthau 54 Hollywood Blvd. 123-4567

Right now I am using the code

Open CommonDialog1.Filename For Input as #File1
Line Input #File1, strText

Open CommonDialog2.Filename For Output as #File2
Print #File2, Texto

Obviously all this does is copy the file but unfortunately that is about the extent of my VB experience. I need a subroutine that will read the file, replace the white spaces between columns with a ";" and also return the column length (e.g. the number of spaces between the A of Adam Smith and the first number of his phone number).

any suggestions will be GREATLY appreciated!

Thanks,

Andrew

Space Delimited Text File
I am working on a subroutine to convert space-delimited files to semicolon-delimited files. Right now the file looks something like this:

Adam Smith 45 Cherry St. 789-0098
Susan Sarandon 123 123rd Avenue 555-5555
Walter Matthau 54 Hollywood Blvd. 123-4567

Right now I am using the code

Open CommonDialog1.Filename For Input as #File1
Line Input #File1, strText

Open CommonDialog2.Filename For Output as #File2
Print #File2, Texto

Obviously all this does is copy the file but unfortunately that is about the extent of my VB experience. I need a subroutine that will read the file, replace the white spaces between columns with a ";" and also return the column length (e.g. the number of spaces between the A of Adam Smith and the first number of his phone number).

any suggestions will be GREATLY appreciated!

Thanks,

Andrew

Text File Query Tab Delimited VB6
OK big problem here
I am kinda new to this so bare with me

I want to take a text file that is tab delimited (output of a pascal program). Then have it seperated into their specific columns in an access database (pre existing).

Example of text file



This is the header of the text file---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Significant Data Below this statement (Column Names then Information)


Position (Tab) Mileage (Tab) Exception
1 123 CW



End


This file can contain lots of these entries. I am hoping I can get this to work. I hate working with 2 previously created files.

I cant get the top paragraph off of it (i guess a disclaimer of sorts). So I would greatly like the help.

Thanks

Creating A Delimited Text File
It's me, the noob, again. My project is going well, but now I'm into the thick of it.

I need to create a delimited .txt file using information from an access database. I have been using DAO thus far.

I am having trouble finding any documentation that tells me how to pull an individual field from a record and write it to file. Any help/advice would be greatly appreciated (once again). thanks,

Jason

Writing A Delimited Text File
i'm trying to write text to an excel file which is delimited by tab, can anyone help?

i've tried this and it doesn't work

File8.Open Dialog1.FileName, _
            fsModeAppend, fsModeOutput, fsAccessReadWrite, fsLockWrite
File8.LinePrint ("a" & " " & "test")
File8.Close

Delimited Text File Assistance
Consider a comma delimited text file:

"John Doe",999-999-9999,02-12-76,"Sales",125.05
"Jackie Doe",666-999-9999,02-12-62,"Repair",125.05
"Jane Doe",777-999-9999,07-22-92,"Sales",125.05
"Jake Doe",555-999-9999,05-12-82,"Service",125.05
"Joe Darrowe",333-999-9999,12-12-82,"Sales",125.05
"John Dorkman",222-999-9999,03-12-72,"Repair",125.05

I am trying to read through this type of file and read each line into
an array assigned for each field... (i.e: Name, SSN, DOB, Dept, Commision)
for each line. Then I want to display an individual report sheet for
each dept. So that when I call for the display of that report sheet it will
display only those persons in that dept.

Also I wanna be able to edit information in those fields and append it back
to the original text file after it has changed.

I am trying to find out how I would go about coding this.

Any help would be greatly appreciated...

Space Delimited Text File
I am working on a subroutine to convert space-delimited files to semicolon-delimited files. Right now the file looks something like this:

Adam Smith 45 Cherry St. 789-0098
Susan Sarandon 123 123rd Avenue 555-5555
Walter Matthau 54 Hollywood Blvd. 123-4567

Right now I am using the code

[vbcode]
Open CommonDialog1.Filename For Input as #File1
Line Input #File1, strText

Open CommonDialog2.Filename For Output as #File2
Print #File2, Texto

Obviously all this does is copy the file but unfortunately that is about the extent of my VB experience. I need a subroutine that will read the file, replace the white spaces between columns with a ";" and also return the column length (e.g. the number of spaces between the A of Adam Smith and the first number of his phone number).

any suggestions will be GREATLY appreciated!

Thanks,

Andrew

Tab Delimited Text File Text Parsing
I have a query that I wrote and ran in SQL Analyzer which produces three columns of information from three different tables. I set Analyzer up to dump the contents of this query to a text file rather than in its grid. I now have a tab delimited text file with the three columns of information.

What I need to do now is read that text file in using Vb, and dump the contents of column one into Richtextbox1, column two into Richtextbox2 and column three into Richtextbox3. How would I go about doing that?

Copyright © 2005-08 www.BigResource.com, All rights reserved