Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 18th, 2003, 04:37 PM
middenaveen middenaveen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Bowling Green, Kentucky
Posts: 22 middenaveen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry how to generate a report of a text file in vb

hi,

I wanna generate a report of a text file in vb.

I am attaching my text file with this.

My text file is of Tab delimited. I can even use a Comma Delimiter also. So please help me in generating a report in a very good format, that may be for a Tab de limited or comma Delimited.

Thanks in advance,

bye
Attached Files
File Type: txt data.txt (247 Bytes, 300 views)

Reply With Quote
  #2  
Old December 18th, 2003, 06:20 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
what format do you want to report to be in?
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #3  
Old December 18th, 2003, 09:51 PM
middenaveen middenaveen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Bowling Green, Kentucky
Posts: 22 middenaveen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry I need in a tab or space delimited format

hi,

Thanks for your reply,

I am trying for a report that has columns and each column is seperated by vertical line. And also if possible each row is also seperated by a horizontal line.

If You have so idea plz let me know that.

I am in urgent, as the dead line has approached, so please help me.

Thanks,

bye

Reply With Quote
  #4  
Old December 18th, 2003, 10:40 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
U can open this file with excel!Try it!If u will generate a report,u can use vba or vb with office reference!.

Reply With Quote
  #5  
Old December 18th, 2003, 11:03 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
There are two main ways to input text. One is to read the information in one line at a time into a variable, and then split that variable into arrays using the split() function and the appropriate variable. This is the best way to do it if you have variable length lines. If you know that each record in your text file will have the same format, with all fields in the same order, then you can read the line into specific variables. Here are both methods displayed, and you can pick which one suits you best.

Code:
Private Sub Form_Load()
Dim strLine As String
Dim strArray() As String
Dim i As Integer
Dim Var1 As String, Var2 As String, Var3 As String, Var4 As String

Open App.Path & "\MyText.txt" For Input As #1
Do Until EOF(1)
   strLine = input(LOF(1), #1)
Loop
Close #1
strArray = Split(strLine, ",")
For i = 0 To UBound(strArray)
    MsgBox strArray(i)
Next i

Open App.Path & "\MyText.txt" For Input As #2
Do Until EOF(2)
    Input #2, Var1, Var2, Var3, Var4
Loop
MsgBox Var1 & " " & Var2 & " " & Var3 & " " & Var4
End Sub

Reply With Quote
  #6  
Old December 18th, 2003, 11:05 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
To follow that up, once you have the variables into an array in memory, you can write them to any type of file you want.

Reply With Quote
  #7  
Old December 18th, 2003, 11:37 PM
middenaveen middenaveen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Bowling Green, Kentucky
Posts: 22 middenaveen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy But I need it in a print format

hi,

thanks for the help u r doing to me.

I did all the job of reading a file using the second type of method u mentioned in ur last reply.

That is my text file has the fixed format records, so i read them into different variables and I got that.

But now the problem I facing is, The text file I have generated using the print #1, var1, var2... is a tab delimited text file.

But that text file, eventhough it is tab delimited, so some fields are of less length and some are ofgreater lenghts, they are not appearing in the actual columns they have to be in, eventhough they are seperated by the tab space.


So I was asked to generate a printable format of that text file, which should look good, like each column seperated by a line and (ach row seperated by a line if possible).


So please look over this, and help me in generating a printable format of the file.

since i have to give an option of printing the text file that is of a very good allignment, like all the respective data should be printed exactly under their respective columns.


That is like, if we have three columns in the text file, and three rows under it should look like, as shown below.


LastName FirstName Age
abc xyz 22
def ghi 21
jkl mno 25



and so on.. with the lastname seperated with a vertical line from the FirstName and FirstName seperated by a vertical line from Age

and their respective rows should also fall under those column headers only...


Please reply me if u have any doubt my specification...


Thanking you,

bye

Reply With Quote
  #8  
Old December 19th, 2003, 01:34 AM
middenaveen middenaveen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Bowling Green, Kentucky
Posts: 22 middenaveen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry hi

hi,

in the past mail, i gave the format there

abc is the lastname. xyz is the first name and 22 is the age.

That abc should be preinted exactly under the lastname and xyz should be printed exaclty under the firstname and 22 should be preinted exactly under age.

In that way all the rows how many it be, all should be printed in a exact format...


ok bye

Reply With Quote
  #9  
Old December 19th, 2003, 09:57 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
OK - so you have to variables in memory, and now the problem is that you need to print them out to a file in the format that you specified, with even spacings between the columns? This is not as hard as you might think, but you need to do something first. You need to come up with a print-spacing chart that will designate the column width of each column in the report. This needs to be wide enough to accomodate your data (wide enough to handle the longest string you might have in a field). Usually, generalizations are made and any data that might be longer than your assumed length is truncated. Therefore, you might come up with your assumed print spacings like this.

FirstName=Spaces 1-20
buffer=Spaces 21-23
LastName=Spaces 24-44
buffer=spaces 45-47
ZipCode=Spaces 48-59
buffer=spaces 60-62

and so on.. let me know what you come up with, and I'll try to show you how to use it.

Reply With Quote
  #10  
Old December 19th, 2003, 10:29 AM
middenaveen middenaveen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Bowling Green, Kentucky
Posts: 22 middenaveen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi

hi,

Thanks for ur reply.

Here I am going to printout the data of a file to a paper.
So I am worrying about " if the row length is greater than the size of the A4 or A3 size paper then what to do.

And also i should print that out with even spacing, i think u got it.


Thanks,
bye

Reply With Quote
  #11  
Old December 19th, 2003, 05:17 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
just out of curiosity, is there any way that you can use excel to help you on that? I'm working on the problem right now, but I'm a little confused. You have to read data in from one file, and then place it in another file in the exact same format?

Reply With Quote
  #12  
Old December 20th, 2003, 01:21 AM
middenaveen middenaveen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Bowling Green, Kentucky
Posts: 22 middenaveen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi

hi,

yah i am going to print my input .doc file to another .doc file.

Such way that all the data is displyed in a tabular form. So that even if a field is of larger length, that can adjusted in the same cell itself in that table.

That is I got this worked when I directly used the table option from the word. I selected all the rows in my MS word file and in
that I took the table option and in that convert + Text to Table

then i got it exactly what I want,
But the problem is I have to print that format from the vb code itself.

If I am not clear, then please open a microsoft word file and then
type some words that are seperated by commas and then select the entire line and then go to Table options menu and in that, then go to the Conver Option and then select the Text to Table option, then u can get all the data that has been comma delimited into the tables. In that you can see that if a feild in the row is of larger lenth than the size of that field, then it is adjusted in that cell itself by enlarging the cell size by itself automatically.

I think I am clear now.

To be frank, I donno much vb programming. I think U understood my problem. i am expecting help from u.

I hope u would help me as early as possible,
Thanking You,

Bye

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > how to generate a report of a text file in vb


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


<