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




Text Align When Outputting To Text File


I have three variables here: item number, description, and price. Each line can be a maximum of 50 characters. I need the first two variables left aligned and the last one right aligned on the same line when outputting to a text file, so it looks like:


Code:
01234567890123456789012345678901234567890123456789
itemno description, color price


I already wrote functions for right alignment but I cannot figure out how to have two different alignments when outputting to the text file on the same line. Anyone have any ideas? Thanks.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Outputting To A Text File
Lo all, i'm new to this so try to bare with me

I've been creating a DataBased based program for
storing people's details. I won't bore you with the details
but its basically a fancy AddressBook with new fields etc.

Could anyone tell me how to create a button that would save
all (or just the current) database entry to a text file?

Its basically so we can print the details off easier without
using "Me.Print" etc.

If its required I can post the source files in a .zip or .rar.

Outputting To A Text File
Hi Everyone,

The below code is working execept for the fact that it is only displaying the very end of the data. "List1" is the name of my textbox. I have the multiline value set to true. How can I make it display all the data into a text box? Thank you.




VB Code:
If Not (IsEmpty(arrkeynames)) ThenFor Each subkey In arrkeynamesregpath = strkey & "Network" & subkeyregentry = "RemotePath"objreg.getstringvalue HKEY_USERS, regpath, regentry, dapath list1 = subkey & ":" & vbTab & dapath & vbNewLine

Outputting To A Text File.
Hi,

Does anyone have any tips (or know of any good web sites/tutorials) for neatly formatting text in an output file (.txt). I'm finding it difficult to get everything lined up with headers, and because some of the bits of data are of different length, all the bits of data in my tables are out of position.

TYIA
Pile

Outputting To Existing Text File
I am a novice programmer.

How do I output the text appearing on a label so that it outputs to an existing text file exactly as it appears on a label?

This is what I have done so far.

Private Sub PurchaseCmd_Click()
Open "D:Documents and SettingsChris LatinoDesktopProjUnmodifiedProjectpao.dat" For Append As #1
Write #1, receipt.Text
Close #1


End Sub

If Statements - Text File Outputting?
I have a program which reads a text file, line by line, then outputs certains lines to a new text file. Heres an example of a 2 lines in my text file.

H 623556348762 company1
D93
D08
H 623556898798 Company2
D08
D01
D34

Each record begins with a H, therefore in the above example i have 2 records. When the code reads the text file, it outputs those records when D08 comes last in the lines, see record 1 above(company1). BUT when D08 comes in the middle of the record it does not get outputted, see record 2, company2. So if theres a D01 or any other line after a D08 line it ignores my Rule to output.

WHY is this happening to me?!! Ive pasted the IF Statements below which take care of the selection criteria. Basically, i need to output all records which have a D08 line , no matter of its position within the record.

Thanks
xx


Paste the code below into a text file to make it more readable.
'' if this record is still okay
''
If useThisRecord Then
'' now check through line by line to see if it contains a D93 record
''
For j = 0 To UBound(strRecord)
'' if there is in fact a D93 record, then check if there's a P field
''
If Left(strRecord(j), 3) = "D93" Then
'' if there is a P at position 62 then this record is not okay
''
useThisRecord = Not (Mid$(strRecord(j), 62, 1) = "P")


If Left(strRecord(j), 3) = "D12" Or Left(strRecord(j), 3) = "D08" Or Left(strRecord(j), 3) = "D93" And Mid$(strRecord(j), 62, 1) = "S" Then

useThisRecord = True

End If
End If
'End If
Next
End If

Outputting Strings To A Text File
Hiya, what I want to do is output a series of string variables to a simple .txt file. I know how to do this, but the problem is it outputs the "" marks as well. I want to get rid of these as they can't be read by another program that reads the text file. However the program I'm writing must be able to read the values in the file back as strings. Can anyone help?

Thanx in advance,

Matt

Need Assistance In Outputting To A Text File
Hello to all,

I have a text file with customers names and their purchases over a 5 month period.  

It would look like similar to whats below:

"Name", "M1", "M2", "M3", "M4", "M5"
"Harry Jones", 250, 300, 450, 100, 250
"Henny Penny", 100, 200, 150, 300, 250
"Tom Mack", 110, 320, 150, 345, 430
"Jenn Street", 320, 280, 450, 320, 840
"Mary Jacobs", 430, 350, 700, 630, 290

Using VB6 and reading this text file, lets call it customers.txt, how can I output each customers name with their calculated total purchases into another textfile lets call it custtot.txt that would look like this:

Customer name  Total purchases for 5 months
"Harry Jones"   1350
"Henny Penny"   1000...

Does this make sense??

Basically I want to be able to calculate their total purchases from the input text file using VB6 and then output these calculated totals to another text file.

What is the quickest & easiest way to do this??

Thanks for any help I may get!

Cheers!

Opening Text File, Outputting It To Textbox
How do I open a textfile, and have it's contents outputed to a textbox? The path must be file.ext .. I looked at some of the tutorials but didn't find a direct example, tried

Dim checkfile As String
Open App.Path & "conf.cfg" For Random As checkfile
txt1.Text = checkfile

which didn't do anything, was a longshot : ... also conf.cfg, textfile saved with the extension .cfg, shouldn't be problem ...

Outputting Data From A Datagrid Into A Text File?
How would you go about this. I have never made a report before so I was wondering if you could tell me the best way to do this. I have a datagrid that contains data, it is logs of events happening in my program, like login, logout, etc, and I am trying to create a function so the user can export the logs to a text file. If you could help I would be very grateful
Thanks

Outputting Multiple Lines To A Text File.
Could someone give me a code snippet for creating and writing to a text file. I need to be able to write multiple lines.
Thanks

Help On Outputting Text File From Excell Cell
I am trying to output the text in excell cells.

For example how do you output text file

A B
1 2 Hello
2 5 Hi
3 28 Good

How can I output a tex file containing B1 with the
file title of A1. I also want to make separate text
files for each row.

Any advice of Help would be appriciatted

Thanks

Kuni

Help Outputting Text File Info To A Listbox
Ok, so I've come up with a program that reads in a list of names and sorts them in ascending or descending order according to the option buttons selected by the user. The only problem is I'm having some trouble outputting this information to a list box so I have no idea if my program works or not. I was hoping maybe someone could tell me what it is that I need to do to get this to output. Could it have something to do with the People subroutine?

Thanks in advance!

Outputting Text To A Text File With Quotes &" &"
Hello,
I do not know what to search under in google for this.
I want to write to a text file a few lines like "hello" (It won't really say hello, that is an example).

However, in VB the Print #1, "blagggggg" doesn't like Print #1, ""Hello""

How do I complete this?

Thank you,
Scott

Vertical Align Text In Text Box / Label Control
I searched on "vertical align" in all forums and did not find this mentioned. (Not that it hasn't been, I just didn't get a hit.)

Anyway, is there a way to vertically align text within a VB 6.0 textbox or label control? (i.e., some programmatic equivalent to the Alignment property) It looks really goofy when the text is crammed against the top of the control ...

Getting some other toolset is not an option. (I am doing this at home for kicks and grins.)

Thanx,

P

Word Text Boxes Align Text?
Is there a way of aligning text to bottom in a text box like you can in the cell of a table?

 

You Can Align Text In A Text Box But Not Rich Text Box????
I dont see a way to centre or align text to the rigth in a rich text box, which such features are there in a normal basic text box.

thats very odd..... Rich text box is ment to be advance with stuff like that no???

or am i missing something here?

can it be done programmicaly maybe?

Abe

Align Text Within Label Or Text Box
Can someone tell me how to vertically align text within a txt box or a label in visual basic 6.

Outputting Text To Net Term
I'm writing code that needs to export data to a text file, but I'm unable to get it to export quotation marks.

For example, I need the text file to read:

Output "rcv:apptext!"

but the code is exporting:

Output rcv:apptext!

I've tried the print to file and write to file commands and neither seem to work. Thanks for your help!

Outputting Text Lines?
I have a text file which contains lines of data. I only need to output certain lines based on the following criteria:-

Each new record begins with "H", ie header record. Then within each header record i can have muliple lines of "D" records, i.e detail records.

For each record beginning with "H" i
ONLY OUTPUT lines, beginning with D08 or D12 or D93

See example test lines below.

example of text file:-
H 20397337568237 company1
D90
D88
H 203866547658769 company 2
D01
D08
H 237693709283470 company3
D08
D01

There are 3 records in the above example. I do not want to output record 1,compnay 1 as it doesnt have a D08 or D12 or D93 beneath it.
I do want to output record 2,companY 2 because it has a D08 beneath it.
I do want to output record 3 , company 3, because it also has a D08 beneath it. However record 3 will not output for me when i use the code below, because D08 is not at the end of line?? Dont know why this is happening, Can anyone re-jig my if statement.


VB Code:
If useThisRecord Then                '' now check through line by line to see if it contains a D93 record                ''                For j = 0 To UBound(strRecord)                            If (Left(strRecord(j), 3) = "D12") Or (Left(strRecord(j), 3) = "D08") Or Left(strRecord(j), 3) = "H20" Or (Left(strRecord(j), 3) = "D93" And Mid$(strRecord(j), 62, 1) = "S") Then                     useThisRecord = True                   Else                   useThisRecord = False                                       End If         ''if there is in fact a D93 record, then check if there's a P field                    If Left(strRecord(j), 3) = "D93" Then                        '' if there is a P at position 62 then this record is not okay                        ''                        useThisRecord = Not (Mid$(strRecord(j), 62, 1) = "P")                    End If                Next            End If

Outputting To Text Files
2 questions:

1) Does anyone know how to export a string to a text file without putting the quotation marks around it.

2) Anyway of stopping VB from zero suppressing integers eg stopping an input 0052 from being outputted as 52???

Outputting Bold Text Using Windows API
Hi

I am using VB6 and am currently drawing some text onto a picture box using the TextOut() function, how do I change the font, font size and make it bold? I can change the colour using the SetTextColor() function, but haven't been able to find how to achieve the other formatting options.

Thanks in advance,

Mark

Outputting Strings To Human Readable Text
How to I output strings as readable text in notepad
i'm using this type of output

Open "c:currentList.txt" For Random As #1 Len = 1000
put #1, 1, variable1
close #1

but this outputs as... machine language..?

Freezing Richtextbox From Scrolling While Outputting Text
Hi all ... just wonder if there is any codes out there that can freeze the richtextbox from scrolling when outputting a long string of text.

My problem is when outputting a large amount of lines into a richtextbox, it tends to scroll along the last line of input. I want it to be fixed at the top of the richtextbox when outputting. Sometimes .. it remains at the top ... but sometimes .. it follows the last line ... this is weird ... probably due to the system graphic memory ...

Appreciate if anyone can tell me how to freeze the richtextbox when outputting.

Thanks !

Chris

Outputting Text From A Textbox To The Default Printer
I would have thought it might be easy to print out the contents of a textbox, and maybe it is, maybe I missed something, either way, how can I take the contents of a textbox in a form in excel and output that to the printer?

Thanks,

-Heathen

Align In Text Box
hi i have an external file named myfile.txt w/c was properly aligned in two columns now wen extracted try to display iton a textbox the texts were not aligned anymore, i used this code

module:

Public Function Combine(txt As TextBox, Sfile As String)
Dim stxt As String
X = FreeFile
Open App.Path & Sfile For Input As X
txt = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #X
End Function

Text Align API... Help
I am printing text in Picturebox, Unfortunately VB doesn't include text alignment except for label or textbox. But there's API function that can get print text alignment in picture box. Check it out

http://builder.com.com/5100-6228-5421501.html

I added.. Declare Sub SetTextAlign Lib "gdi32" (ByValhDC As Long, ByValwFlags As Long) At very top (Where Option Explicit are) and I get complie error... So I am not sure how to implement it since I am not very familar with API calls, So help me.

Code written already on my form, where do I implement Text Align API function in my form?

Code:
Option Explicit

Private Sub Form_Load()
Picture1.FontBold = True
Picture1.FontSize = 12
Picture1.FontName = "Arial"
Picture1.ForeColor = VbWhite
Picture1.BackColor = vbBlacK

End Sub

Align Text Vertically ?
In any label.caption or txt.text
There is option in Properties windows to align text Horizantly (left , Center,Right) But
But there is no Option seen to Align text Verticaly (Top,Mid,Botom).
If there is no available then how can I do this ?

Align Text In MsFlexGrid
Hi,

i have a problem with flesgrid here:

After loading the data into the flexgrid. i realised that some of the data in the cells are either aligned to the left or right.How can i standardise the alignment of the text in every cells?

Apart from the above, i would also like to know whether can i add rows (flexgrid) using codes rather than specifying in the property? I'll be better if a sample code can be provided.

Thanks a million,friends!

Regards!

Align Text To TextBox
I have a form that has one line of text and a textbox. I would like to align the text to the left of the textbox, and centered vertically to the textbox. Is there a way to do this without typing in coordinates or turning off the snap-to-grid and moving it manually? Or, am I just missing the fact that you can do labels for the textbox itself...and all this is taken care of automatically? Thanks in advance!

Toolbar Text Align Help
hi,

Can someone help me or give some info on how to set the Text alignment on the button to the left in a Toolbar, all I can see is tbrTextAlignBottom and tbrTextAlignRight

using the tbrTextAlignBottom is just totaly usless cos there is like a large gap, and if I use the tbrTextAlignRight it just looks even wose and just makes the buttons looks unnatural as the text is closer to the next button.

is there any API call I can use. or anything else.

How To Align Text In A List Box
hello everyone, below is a screen shot of my program.



The text in the list box is read from a text file when the refresh button is clicked.

What i wish to do is align the text so that it comes under the headings like this: (i edited it in paint to give you gys a visual representation :P)



i have attached the whole vb program so you gys can have a look.

Thank you

Using Space() To Align Text
Is it possible to use Space() to get text to left align with headings? Here is what I'm doing now and the result is shown in the attached file.

VB Code:
strMsg = strMsg & "TAG" & Space(11) & "VARIABLE" & Space(11) & "STATUS" & Space(11) _    & "VALUE" & Space(11) & "UNITS" & Space(11) & "TIME" & vbCrLfstrMsg = strMsg & "27-QAO49D" & Space(11) & "PD Pull Roll" & Space(11) & " " & _    Space(11) & "BREAK SHEET" & Space(11) & " " & Space(11) & "15-Sep-05 12:00:00"

Align Text Verticaly ?
In any label.caption or txt.text
There is option in Properties windows to align text Horizantly(left , Center,Right) But
But there is no Option seen to Align text Verticaly(Top,Mid,Botom).
If there is no available then how can I do this ?

Align Text In A ListBox
Is there an easy way right align text in a listbox? I'm currently using tabs to set the colums, but the columns are left aligned and i need my last colum (Numbers) to line up by decimal. is this possibal?

Thanks,

nathan

To Align The Text Box With The Form.......
Hi everybody,

I have created a notepad application. My problem is whenever i maximize the form the text box on the form does not maximize properly or does not fit to the size of the form. I used the resize event of the form. I assigned the height and the width of the form to the height and width of the textbox. But the scrollbars are not adjusted properly. I want that it should maximize properly or fit to the size of the form and also the scrollbars of the textbox should be visible clearly.

Regards

Samir

Align Text In A Label
Is it possible to set text in a multiline label to justify? I don't want left, right or center alignment.

Thanks

Align Rich Text
Is it possible to align the text in a richtext box center?

Textbox.text Can't Right Align...anyone Know If
this a know bug in visual basic?

is there a work-around?

Align Text In A Message Box
Hey guys. has anybody else tried this? it doesn't work.
strMessage = ""
for x = 1 to 5
strMessage = strMessage & vbCrLf & strArray(x)
For y = 1 to (70 - Len(strArray(x)))
strmessage = strMessage & " "
Next y
strMessage = strMessage & strArray2(x)
Next x
MsgBox(strMessage)

What is this for? It should take these 2 arrays and make even columns out of them. But it doesn't. The number of characters in the first array aren't always the same width and so the second column is not aligned.

Since I won't know what is going to print in this array, I can't "make" it line up.

Any thoughts?


Thanks
wengang

Align Columns In Text Box
I have a text box in which multiple columns of figures are displayed as they are computed within my application. Each column may have a varying number of digits or letters.

I want each column to begin at the same relative position in the text box so visually I don't end up with uneven columns. The right side of each column doesn't matter. I realize the font may contribute to unevenness depending upon the character so which font would give me the best results? I don't have a problem with the hard copy output since I convert the contents of the text box to a file and use tabs in the printed results.

Is there a simple way to do this? If I could use tabs in the text box, it would solve the problem. I suppose a series of text boxes (1 for each column) would also work but that would really be a pain. Since the data may go for many lines, I need to have scroll bars or maybe a picture box would do, using currentx,y. I appreciate any advice or solution.

 

To Align The Text In Richtextbox
hai guys,

I am using the form named as billing repot. In this form,we have print button to pritn the content of the bill details in the richtext box. my code is working fine,but all the details of the bill is to be printed in overwrited format.My ques tion is how to align the space for print the bill details in the rich textbox.



Code:
Public Sub PrintView(title As String, query As String, n As Integer, column As Variant)
Dim rs1 As New ADODB.Recordset
Dim colwidth(7) As Integer
rs1.Open "select b.billno,b.bdate,c.caddr,b.quantity,b.rate,b.discount,b.netamt from billing b,CREGISTER c where b.clientname=c.clientname", con, adOpenDynamic, adLockReadOnly
Dim col, ss, sp, Line As String
Line = String$(99, "_") + vbCrLf + vbCrLf
colwidth(0) = 15
colwidth(1) = 10
colwidth(2) = 35
colwidth(3) = 20
colwidth(4) = 25
colwidth(5) = 30
colwidth(6) = 40
colwidth(7) = 45
col = Space(36)
sp = Space(15)
ss = Space(37)
Dim rs As New ADODB.Recordset
rs.Open query, con, adOpenDynamic, adLockReadOnly
View = ""
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(5)

frmprintbill.RichTextBox1.Text = rs1("billno")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(10)
frmprintbill.RichTextBox1.Text = rs1("bdate")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(15)
frmprintbill.RichTextBox1.Text = rs1("caddr")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(20)
frmprintbill.RichTextBox1.Text = rs1("quantity")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(25)
View = View + vbCrLf + vbCrLf + vbCrLf
frmprintbill.RichTextBox1.Text = rs1("rate")
View = View + Space(30)
frmprintbill.RichTextBox1.Text = rs1("discount")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(35)
frmprintbill.RichTextBox1.Text = rs1("netamt")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(40)
View = View + Space$(5) + title + vbCrLf + vbCrLf
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Line
Dim j
For j = 0 To n - 1
    If j = 0 Or j = 1 Then
        LSet col = rs(j)
        View = View + sp + col
    Else
        LSet ss = rs(j)
        View = View + sp + ss
    End If
Next j
View = View + vbCrLf
View = View + Line
While Not rs.EOF
'Dim i
    For i = 0 To n - 1
        If i = 0 Or i = 1 Then
            LSet col = rs(i)
            View = View + sp + col
        Else
            ss = Space(colwidth(i))
            LSet ss = rs(i)
            'View = View + sp + ss
            View = View + ss
        End If
    Next i
    View = View + vbCrLf
    rs.MoveNext
Wend
frmprintbill.Show
End Sub
[code]

Plzzzz trace the code and swend the solution for me.


bye
ram

How To Align Text In RichTextBox
Can anybody help me?

I want to print the text from the richtextbox in the format aligned by the user. How shall i go for it?

Thanks

Vertically Align Label Text
This is probably a really silly question, but is it possible to vertically centre text displayed in a label?
Any help greatly appreciated

How To Align Text In A Flexgrid Cell??
Could anyone plz tell me how to center your text within a cell
in a flexgrid??
I have to do this for a project for school and I can't find it
Please help me out

Align Text To Right Side In Textbox?
hi

I have a textbox (Text1) and have a large amount of text which fills the textbox and beyond.

How do I align this text such that the last character is always aligned to the right of the text box (and is visible)?

cheers

Text Align Property When Unavailable
How can I left-align the caption of a command button? Is there any trick using the API functions?

Align Text Box Array With List Box
I have a list box and wish to be able to enter data to the side of the list box , for each item in the list box
eg
List box                         Text Box
aaaaaaaaaa                       mmmmm
bbbbbbbbbb                       pppppp

I have set the text box up as text1(0)  etc so that i can
create an array beside the list box

Is there any way of getting the depth of the text box = depth of the list box or visa versa.

Or is there any other trick of being able to enter data beside a list box , line by line.

I suppose at a last resort i could put the data to a table and use a data entry box.


Appreciate any help or ideas.


Align Text With Column Headings
Good day

I would like to have code to align the text within the headings. I have the following headings :
Name: Surname: Comments:
The code is printing but the text is not aligned especially the comments column where the text sometimes overlaps to the next line.

Thx in advance



bednarjm - move to vb6 forum




Edited by - bednarjm on 7/16/2008 10:49:43 AM

How Do You Align Header Text In A Datagrid?
Is it possible to align text in the headers of a datagrid?

TIA
Deke

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