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




Save Text With Out Extra Lines


i have a code that saves some settings in my app like a picture path for the background
i use the rtf as i dont want to code a lot of code just to save a text doc. i got it to save a text doc but it saves with 1 or 2 lines with nothing on it and when i load my app. it does not work because of these lines.
can i get my app to save text on only one line no matter how long the path is?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Deleting Extra Lines From Text File
Hi,

I have a text file, that can be continuously added to and deleted from, but I can't seem to get the blank lines from where the data has been deleted to go away. Any help would be greatly appreciated!

Adding Extra Text Lines To File
I'm making a function that adds a line of text to a text file everytime it's called. Unfortunately this just replaces the first line with new text:


VB Code:
Public Sub Write_To_File(File_Path As String, Message As String)     Open File_Path For Output As #1                    Print #1, Message        Close #1 End Sub


Any ideas on how to solve this?

Save Array Data As A Text File Of 65 Characters Lines
Um Ubound(M) 'where M() is an array of bytes.
To save content of M as a text file where lines are 34 characters each(the last one will be 34 chrs or less), I can write the following code:

Open MyFile For Binary As #1
rew = StrConv(M, vbUnicode)
For i = 0 To (Um + 1) 34 - 1
Put #1, , Mid(rew, i * 34 + 1, 34) & _ vbCrLf
Next i
Put #1, , Right(rew, Len(rew) Mod 34)
Close #1

AY mentionned the CopyMemory function but I can't make it work if original data is contained in an array

thank you

How To Remove Extra Lines From Textbox Or RichTextBox
How To Remove Extra Lines From Textbox Or RichTextBox?

my TXTBOX look's like
----------------------------------------
NAME


















NAME
--------------------------------------


How can i make it look like

------------------
NAME

NAME
------------------


i am pissed @ this plz help !!

Printer.print Leaving Extra Spaces Between Two Lines
Hi,

I am using Visual Basic 6.0 to develop a POS application. The application requires two printers to be used for printing purposes - 1. An Audit printer and 2. A Slip printer.

At times in my project, I need to print to both the printers simultaneously. For eg: When I process a bill, some information is first written to the slip printer, then the same information is written to the audit printer. To demonstrate the above scenario, I have a sample snippet of code where a block of text is printed simultaneouly to the audit printer and slip printer in a loop. The loop iterates thrice. The sample code is given below :

********************SAMPLE CODE STARTS*********************

Private Sub Command1_Click()

Dim P As Object

Printer.TrackDefault = False

Dim ycord_slip As Variant
Dim xcord_slip As Variant
Dim ycord_audit As Variant
Dim xcord_audit As Variant

ycord_slip = 0
xcord_slip = 0
ycord_audit = 0
xcord_audit = 0

For i = 1 To 3

For Each P In Printers

Set Printer = P

If P.Port = "LPT1:" Then

'MsgBox xcord_slip & " ---- " & ycord_slip

Printer.CurrentX = xcord_slip
Printer.CurrentY = ycord_slip

Printer.Print "Printing to Slip printer - Count : " & i

ElseIf P.Port = "Ne00:" Then

'MsgBox xcord_audit & " ---- " & ycord_audit

Printer.CurrentX = xcord_audit
Printer.CurrentY = ycord_audit

Printer.Print "Printing to Audit printer - Count :" & i

End If

Next P

xcord_audit = 0
ycord_audit = ycord_audit + 100

Next i

Printer.EndDoc


End Sub


********************SAMPLE CODE ENDS*********************

Herein lies the actual problem with the audit printer. As per the above logic, the audit printer should print the following:

Printing to Audit printer - Count : 1
Printing to Audit printer - Count : 2
Printing to Audit printer - Count : 3

The audit printer prints the above information correctly but leaves lot of space between the lines which I want to get rid off. Where am I going wrong?

Any early help will be highly appreciated.
Thanxs in advance.

****OPERATING ENVIRONMENT****
OS - Windows XP Professional
Langusge - Visual Basic 6.0

Text Box Text Adding Extra Space At End When Saving To DB
This is happening on only one out of about 20 forms that I have created...and I cannot pinpoint the reason for it...but would be interested in a possible solution.

I have appx. five text fields that are adding a space to the end of the string.

For example, I get some data like this: "myname "

See how there is a space at the end of the letter e? It is only occuring on this one form. Any ideas on how to get rid of this? Would a trim do the trick? Thanks in advance.

TempDyna.AddNew
TempDyna("User_name") = ConWriteID
TempDyna("F_name") = TxtFName.Text
TempDyna("L_name") = TxtLname.Text
TempDyna("Buyer_cd") = TxtUserCode.Text
TempDyna("admin_yn") = chkCWadmin.Value
TempDyna("Term_id") = TxtTermId.Text
TempDyna("ofc_symbol") = TxtOfficeSymbol.Text
TempDyna.LockEdits = False
TempDyna.Update

Extra Text In File
How do I get rid of it??? ex:

This is the text want.%^%#&*(ExtraText

I want to get rid of that text in bold.

Extra CHR In Rich Text Box (Resolved)
I am having trouble saving the contents of my rich text box to a csv file. The contents are HTML with tags, and are being output to my csv file with the write command. The problem is i get a square at the end of every line. My guess is its some sort of line break or chr, but i need to know how to get rid of it since it is screwing with my importing program. Any help would be appreciated.

RESOLVED Extra Line From Text
i am using code to input text into a text box from a text file

VB Code:
Open "C:Text.txt" For Input As #1   Do Until EOF(1)Line Input #1, DataText1.Text = Text1.Text & vbCrLf & DataLoopClose #1End Sub

This works fine except there is an extra blank line at the top of the text box, i dont know how to stop this happening. Can anyone help me?

Thanks for any and all help.

Save In Lines...
hi. Im making a Rpg game with a wierd coding.
My Main Page is made out of 29 x 15 images. Each of them recieves a value that i load from a text file that is also saved in a 29 x 15 format. Depending on the value, the image will have specific picture.

but once i change one of those values, i dont know how i can save the values back in the text box in lines like it did before.

heres what the text box looks like.

11111111111111111111111111111
10c777777777ddddddd7777d00001
100000000000c77ddd5fggh900001
100000000000000cdd5ijjk900001
10000000000000009d5lmmn900001
10000000000000009ddb00ad00001
10000000000000009dd5009000001
10000000000000000005009000001
10000000000000000000000000001
1000000000z000000000000000001
10000000000000000000000000001
10000000000000000000000000001
10000000000000000000000000001
10000000000000000000000000001
11111111111111111111000011111

here is my code that loads these values in the images.

Dim ligne As Byte, colonne As Byte
Dim planche(nblignes, nbcolonnes) As String
Dim l As Byte, c As Byte
Const nbcolonnes = 29
Const nblignes = 15



Dim texte As String
Open App.Path & "Map2.txt" For Input As #1
For l = 1 To nblignes
Line Input #1, texte
For c = 1 To nbcolonnes
planche(l, c) = Mid(texte, c, 1)
Next c
Next l
Close #1


all i need is some coding that will let save changes i make to these values back in line format so i can load them again and again. Do you think you could help me???

Rich Text Box Problem, Extra Line
im opening a text file and putting it in a richtext box. this is the way im putting it in the box.

[code]
Do While EOF(2) = False
Input #2, temp
mainText.Text = mainText.Text + temp + vbNewLine
Loop
[code]

the only problem with that is that it adds an extra line because after the last line is read it still adds a vbNewLine.

one way i thought of fixing this is just to simulate a backspace after the richtextbox is filled, but i dont know how to do that.

Ignore Lines In RTB Than Save
How can I like read the text in RTB, Skip a few lines on the top and the bottom then save it?

Moving Lines In A Text Lines
I am creating a replay for a game and I am keeping the info for it in a text file but after 5 seconds I want to clear out anything over 5 seconds old and continue to add. I can figure most of it out cept for the whole part about it removing the first line and moving the rest of the lines up. I am adding to the file every 1/2 second for 5 seconds. Heres what I have so far....


VB Code:
Open "C:Game
eplay.txt" For Append As #1TotTime = Int(Timer) Print #1, Int(Timer); "lblbox(" & Index & ")"If Int(Timer) - TotTime = 5 Then


lol, not much but I can't figure out how do move the lines. Would I just kinda have a second file and copy the lines into the new file and just clear out the old one and so on? But that doesn't seem like an appropriate way to go. Any help with this situation would be muchly appreciated. Thank you and good day.

Remove Extra Line When Writing To Text File
Remove extra line when writing to text file
Hi,

When I open a file for writing text using the print# and write# statement,
there is always a new empty line after the end of the last line.
For E.g.

Text1 <--- start line
Text2
Text3 <--- last line
<An empty line>

Is it possible to get rid of this empty line, that is the cursor should stay
at the end of "Text3" ?

Thanks in advance.

Writing To Text Files Adding Extra Space
Hey all,

When I try to write to a file putting data from two list boxes it is adding an extra space in between the two list boxes data that is messing up my order when putting them back into the listboxes.

Here is my code... why is it putting a space after lstDisplay1's data is put into the file??


VB Code:
Dim j As Integer            Open Dir & File1.List(File1.ListIndex) For Output Lock Read As #1                For j = 0 To lstDisplay1.ListCount                    Print #1, lstDisplay1.List(j)                Next                Print #1, "//"                For j = 0 To lstDisplay2.ListCount                    Print #1, lstDisplay2.List(j)                Next            Close #1

Writing Text Box To File Creates Extra Line.
Hello,

I have an interesting problem that I don't know how to solve.

txtText.text =

Quote:





"sdasdkja lsdal skj sdf d
sdf sdfs df
sdfsdf
sddfdf dsf sd fdfww
d"






When I write to a text file from a textbox with this code:

VB Code:
strFilePath = "C:VBFile.txt"    Open strFilePath For Output As #1      Print #1, txtText.Text    Close #1


File.txt looks like: (The quotation marks in this file are not saved)

Quote:





"sdasdkja lsdal skj sdf d
sdf sdfs df
sdfsdf
sddfdf dsf sd fdfww
d
"






As you can see, when I write the file with the code above it adds an extra break line. Is there a simple way to fix this?


Thank you.

Save Picturebox (with Lines And Label) To Bmp
Hi,

My application has a requirement where I plot a hugh diagram on picturebox based on some data-analysis.
This diagram is drawn by creating Line, label and command button controls on runtime and placing them on picture box. The contents of picture box are not really picture as I really act on the events recvd from label and command buttons.

Now my problem is that when I try to save this image to bmp file I don't get all the contents correctly.
Effectively I'm not able to capture all the contents of PictureBox correctly. I'm using BitBlt to this.

So pls enlighten me on what is the best way to do this?

Thanks in advance
Mandeep

Don't Save The Emty Lines, Or Not To Open Them?
I have a text file that I want to save from my program. But I don't want to
save the empty lines. I want to delete everything after the last character,
Is that possible?

Then when I read the text file i don't want to read empty lines(If the user
as edit the file in notpad..), sense it makes commas at all new lines and
then split the text at every comma in to an array.
The array will contain empty "slot's" if there is a lot of commas in a raw
(like it will be if there is many empty lines at the end/beginning of the
file)

This is the text file:

http://www.google.com,Google
http://www.dustin.se,Dustin
http://www.Microsoft.com,Microsoft

Yours, Jonas

How To Remove An Extra Line Feed From A Text Field In CSV File
Please help! I need to remove the extra LF from the first column of the second row, which caused the information after it to move to the next line. Therefore, I now have 4 rows instead of 3.

"Fox Forward: 'Wake'","FoxFWRD:Wake","","TV-PG","01-Feb-2008 07:19:03 AM"
"Red Bull Xtreme Freeride Contest Verbier: 'Contest Introduction
'","Verbier: Part 1","","TV-PG","01-Feb-2008 07:23:38 AM"
"Elizabeth","Elizabeth","R","","01-Feb-2008 09:29:39 PM"

I have hundreds of files containing thousands of rows that need to be cleaned up before it can be imported to SQL database. I have tried the REPLACE(curline, vblf, "") or REPLACE (curline, chr(10), "") but it doesn't work. I have to automate this process so that the files (from FTP) are being cleaned up daily.

Thanks.
Yolanda

Registry (Save And Read) And Get The # Of Lines In A String!
Since I don't know how to properly use API, can someone please write me a code that has 2 functions (1 for writing strings into the registry and the other for reading from the registry!). Thanks for your help.

Load Ini File, Replace Some Lines, And Save It.
I am trying to open a .ini file to do a few line changes, it seems to work but I can't find a "simple" way to save it back to the file. It's curently in a variable called Otext as String. If I use Print Otext , the right thing appears but I have to send that to a file. Please help.
Thanks
Joel

Insert Multiple Lines Of Text Into An Email From A Text File
Hi All,

I am looking for a way to read multiple lines from a text file anything upto 100 and then insert those into the body of an email message.

I can send the email as I know how to do that it just the reading of the text and then puttiong it into the email that I have a problem with.

Any idea's,

Regards,

Oz

Sending Multiple Lines Of Text To A Text Box, From A Loop.
I am creating a program that needs to create several lines in a text box, based on a certain criteria. However, the way I've written the sample is not acceptable.
So my question is, Can you send multiple lines to a text box, using a loop, to generate the lines of text?

When you run the sample, you'll see what I'm trying to do, but I don't like it, can you help?

Basically the loop would be easy, but I just don't know ho to send the multiple lines of text to the text box from the loop.

VB 6, Problem Displaying Lines Of Text In A Text Box.
Hello, I'm new to VB 6.0, as my name suggest's, :P and I've hit a snag after writing almost the whole program!

I'm trying to write a program that allows a user to choose an VAR from a combo box (CMB_VAR), enter a value for that VAR in a textbox(TXT_VALUE), then use a click event (LBL_ENTERVAR) to display the VAR and value in another textbox(TXT_CFG) within the program, and finally click a button to write the VAR(s) and values to a txt file.

The problem I'm having is i don't know how to send the VAR and value to the textbox(TXT_CFG), I've tried-


VB Code:
Private Sub LBL_ENTERVAR_Click()TXT_CFG.Text = CMB_VAR.Text + " " + TXT_VALUE.TextEnd Sub

-But all it does is destory the previous value.

I need to know how to write to TXT_CFG and retain all the VAR/values the user enters, I also need the values to be entered on a seperate line in TXT_CFG.

EXAMPLE:
line 1 VAR1 value
line 2 VAR2 value
line 3 VAR3 value

PLEASE help me!
If anyone post's code could you comment it as much as possible?

Thanks in advance for taking time out of your day!

Adding New Text Lines In Text Box From Another Form
Hi,

A couple of questions.
I have a main form which consists of a combo box that lists a job type, and 4 text boxes that list the number of square metres, the quantity, the subtotal (sqm * qty) and txtTotal. I have a cmdAdd button which calculates the total as I go along and adds each item as required. In another form I have an invoice which has a header and a footer, and when I click the cmdAdd button on the main form, it inserts the details from the cmb and txt boxes in between the header and footer in the txtInvoice text box. My problem is in doing that. How do I code so that every time I click the cmdAdd button, it adds the current text and combo box values to the txtInvoice.Text. Then when I change the job type and it's associated details and click cmdAdd again, it inserts another line into the txtInvoice.text box so that if I do 5 different cmdAdds I'll have 5 text entries in between my header and footer on the other form. I can do this easily with 1 entry via a variable strInvoice (e.g txtInvoice.txt + header + frmMain.strToInvoice + footer), but I can't work out how to do if for multiple entries. I click on cmdInvoice to view the current status of the invoice with it's current entries.
Here's what the invoice form SHOULD look like after 5 entries (cmdAdds) from the main menu:

           INVOICE
           _______

Date:    09-08-2003



   Item         Price($/sq.m)    Q-ty (sq.m)    S/Total ($)
  _____        __________    ____________    _________
Carpeting         10        1         10
Painting         15        3         45
Roofing         18        1         18
Carpeting         10        2         20
Roofing         18        1         18
 



            TOTAL:      111 $



    _________________ ( )


(sorry, I can't seem to align the columns in the preview well, they are aligned in my app)

How do I insert those listings?

My other problem is with the date. How do I change the date to look like:
    Date:    8/09/2003
instead of:
    Date: 09-08-2003

The code I have for that part is:

Code:Header = vbTab + "INVOICE" + vbCrLf + vbTab + "_______" + vbCrLf + vbCrLf + vbCrLf + "Date: " + Date$ + vbCrLf + vbCrLf + vbCrLf + " Item" + vbTab + vbTab + "Price($/sq.m)" + vbTab + "Q-ty(sq.m)" + vbTab + vbTab + "S/Total($)" + vbCrLf + " ______" + vbTab + vbTab + "___________" + vbTab + "__________" + vbTab + "________"


(excuse all the extras there, just want the date part really)
when I use the Date function by itself I get runtime error 13, type mismatch. In stepping I see the correct date assigned though.

All ideas appreciated
thanks

VB

Save Text = Save Text && Text1
How would i make it so when i save the text in a textbox with

Open Text2.Text For Output As #1
Print #1, Text1
Close #1

that it will not rewrite the txt file but continue writing in it

How Do I Add Multiple Lines Of Text To A Text Box
how do i add multiple lines of text to the text box, i know the multiline option but i dont see how to add more than one line to the textbox

how do u do this?

How Many Lines Are There Of Text In A Text File?
Can anyone tell me that
How many Lines are there of Text in a Text File?
even it should count the blank line between the paragraphs


Regds

Sam F.

Lines In A Text Box
how do you determin how many lines there are in a text box? or even better, a quick way to verticle wrap a multiline text box, any help is appreciated.
ollie.

Lines In A Text Box?
Hi All,
Just a simple question. I was wondering how many lines a basic text box can hold? or if knowone knows the lines, how many alphanumeric characters it can hold?

Thanks

TExt Box New Lines
i have made a small file encryption prog (if you want the source tell me, its not very good though)
the problem was i do know who to tell the text box to go onto a new line (the text box is sent to multiline)

also, is it possible to read a whole file into one variable instead of just to the first character return.

GREK

Text Lines
I have a text box which is multilined (text1) and I have another box which is not (text2) when the user fills in text2 I add the input to text1 using the follwoing code.

If Text2 = "" Then
Else
Text1 = Text1 + " -" + Text2
Text2 = ""
End If

and it works fine but I want it to add each input on a seperate line.Right now every input is put on the same line how do I fix this?

New Lines In Text Box
I have a string that has several line feeds in it. When I place it in a text box, it won't show like it should . It is all placed on one line until it reaches the end of the text box and then forms a new line. Any ideas?

Text Box Lines
how do i replace with "" in a text box, all the lines that start with a character?

Save Text From Two Text Boxes Into 1 Text File?
I have two text boxes. Is it possible to save Text1 and Text2 into the same file, so that the new text file containing both Text1 and Text2's text will be like:

This is the text from Text1's text box

And this is Text2's text

Making a new line to seperate them, if you know what i mean?

Multiple Lines Of Text
i want to do something like this

Private Sub Command1_Click()
select case lbl1.caption
case = "whatever i have here"
lbl2.caption = "i need to show multiple lines
of text so it looks just like
this when it prints to the lbl2"
end select

End Sub

the problem i am having is that when i put the text in multiple lines like that all the lines except the top one turn red and i get a sytex error. is there a way to do this. the reason i want to do it this way is that i will be doing a lot of copy and paste for my label text and i am using as few labels as i can so im using "select case" to change them.

Text Boxes, New Lines.
Hello,
I am creating a simple command line application and i have two text boxes: A command box, and a status box. When you type a command, the result is added to the status box but when you've done to many you can no longer see them. And i dont want scrollbars, cos they look tacky, but when i press enter i need to view the new text been added to status box.

I attached the form.
txt_Do is the command box.
txt_Status is status box.

Thanks, Rowan.

Remove Text Box Lines
I got text loaded into a text box, but need to remove the first 2 lines. Can anyone please tell me?

Thanks in advance

Multiple Lines Of Text.
I need to know how to get multiple lines of text in lables snd message boxes. I have been using a different lable for each line of text, but there has to be a better way! If any one can help me I'd be greatful.

How To Read Different Lines In Text?
i want to read line 7 for example and input it's values.. how can i do that?

Reading Lines Of Text
ive found out how to read a line of text from a text file, how do i move down the text file one line at a time after each click of a mouse.

I am currently using

line input #1, string

this will only display the first line of text

Lines In Rich Text Box
i have a multi line rich text box in which i write a paragraph.

i want some code that goes through the rich text box and picks out each individual line.

for example, if i typed in the following:

'Hello
How are you?

I am fine.'

and ran the code i would get the information:
Line 1 - 'Hello'
Line 2 - 'How are you?'
Line 3 - ''
Line 4 - 'I am fine.'

and so on for however many lines there are.

how can i do this?

Lines In Text File
I'm not sure if I should be posting this here but I figured someone here would know this.

Are the # of lines in a text file limited by memory space or a numeric value.

Thanks

HELP! Randomizing Lines Of Text?
I would like to randomize the following lines of text so they come up in a different order each time and all 12 lines must also be used?

Any suggestions?

txtSchedule.Text = _
" 3 - 5 | 12 - 11 | 6 - 4 | 7 - 9 | 1 - 8 | 2 - 10 |" & vbCrLf & _
" 6 - 10 | 4 - 9 | 11 - 2 | 8 - 7 | 3 - 1 | 5 - 12 |" & vbCrLf & _
" 12 - 7 | 4 - 3 | 9 - 5 | 11 - 6 | 1 - 2 | 10 - 8 |" & vbCrLf & _
" 1 - 12 | 2 - 4 | 6 - 3 | 9 - 10 | 7 - 11 | 5 - 8 |" & vbCrLf & _
" 8 - 11 | 3 - 9 | 10 - 7 | 5 - 2 | 12 - 4 | 1 - 6 |" & vbCrLf & _
" 7 - 1 | 12 - 3 | 9 - 2 | 10 - 4 | 6 - 8 | 11 - 5 |" & vbCrLf & _
" 10 - 12 | 4 - 11 | 9 - 1 | 5 - 6 | 3 - 7 | 2 - 8 |" & vbCrLf & _
" 11 - 10 | 9 - 6 | 2 - 12 | 7 - 5 | 1 - 4 | 8 - 3 |" & vbCrLf & _
" 4 - 5 | 3 - 11 | 1 - 10 | 7 - 2 | 8 - 9 | 6 - 12 |" & vbCrLf & _
" 12 - 8 | 5 - 1 | 2 - 6 | 10 - 3 | 4 - 7 | 11 - 9 |" & vbCrLf & _
" 5 - 10 | 8 - 4 | 3 - 2 | 9 - 12 | 11 - 1 | 7 - 6 |" & vbCrLf & _
" 5 - 3 | 11 - 12 | 4 - 6 | 9 - 7 | 8 - 1 | 10 - 2 |" & vbCrLf & _
""
TIA

Connecting Several Lines Of Text
Hi,
I have some text that I need included in a string in my VB code. It's included in brackets, but I'm getting all of these reallly annoying "Expected Argument" Errors. How do I connect the lines up as one "continous" string at the end of each line, because it doesn't fit on one line. I tried the _ operator but it doesn't work.


Any ideas??
Thanks,
D


---------------------------------------------------------
String = " Hello world
How are you today "
---------------------------------------------------------

Printing Lines Between Text
I would like to put lines undeneath, and on either side of the text..
so that everything is divided up into rows and columns.

I also want to give the user the option to have lines printed or not with an option button.. Thanks

Printer.Print "John Doe",Tab(12);"4532 S Oak St"
Printer.Print "Juan Lopez",Tab(12);"777 S 3rd St"
Printer.Print "Santa Claus",Tab(12);"1 North Pole"

Skip Lines With Just Text...
Hi,
i have a loop....


Code:
Open "test_file.txtl" For Input As #1
Dim strArray() As String

Do Until EOF(1)

Line Input #1, strString

strArray = Split(strString, ",")
List1.AddItem strArray(0)
List2.AddItem strArray(1)

Loop

How can i get the loop to ignore lines of text that dont contain any commas "," or any lines that start with hash mark "#"

Thanks for any help,
-Dave

Msgbox, Two Lines Of Text
hi, i have a msgbox:

msgbox "hello good bye"

how do i make the good bye be on a line below hello

Thanks

Lines In A Text File
Im making a program for learning [Pronomen] for german words:

Der Baum
etc....

I want to display a label that says how many questions (lines) there are in the file #1 and then how can I add a limit to how many lines it can read in?

Can u give me some help please?

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