Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find spaces in a string; Write a line in a txt file

Status
Not open for further replies.

kruxty

Programmer
Jul 17, 2001
197
0
0
PT
I have two doubts!
How can i find a space in a string?
The second one is: how can i write a string line by line, instead of writing it in front of the other string?
 
Hi,

to find a space in a string you can try this.

If InStr(1, txtString, " ") Then
MsgBox "Space found"
Else
MsgBox "Space not found"
End If

What do you mean by writing a string line by line.
Do you want to write to a file?
Explain please
 
Thank you for the "space" help.
And yes... i want to write to a file!
My problem is that when i'm writing it with the Print command, the string will be written in front of the other string.
example:
1 - Test
2 - Car
3 - Visual

This will appear in the file like this:
TestCarVisual

And what i need is this:
Test
Car
Visual
 
Ok,

Say you have a textfile Text.txt in the same directory of your application.
Then the code would be something like.
You save what is in your textbox 'txtString' into your file


Open App.Path & "\Text.txt" For Append As #1
Write #1, txtString
Close #1


Good luck
 
That is what i have been doing... instead of write i use print because of the " ".
But doing what you said you just write the string in front of the other, like i explained before!
 
This should work...

Code:
Open App.Path & "\Text.txt" For Append As #1
print #1, txtString
Close #1

If it doesn't, I would suggest manually inserting a new-line character, followed by a carriage-return. That would make the code look like this:

Code:
Open App.Path & "\Text.txt" For Append As #1
print #1, txtString + chr(13) + chr(10)
Close #1
 
I think if you put a semi-colon at the end of your line it does what you require. eg:-

print#1, txtstring;


 
Ok my friend this should work.... In my contacts database that I`m building this work so it should work for you. All you have to do is edit the code.....

The main peice of info... is usinv the vbLine Stuff

Public Function FullAddress() As String
'Return a string containing the full name and address.
'If no name or address, return an empty string.

If IsNull(LastName) Or IsNull(Address) Then
FullAddress = ""
Else
'Build the address string.
FullAddress = FullName & vbNewLine & _
Address & vbNewLine & _
City & ", " & _
StateOrProvince & " " & PostalCode
End If
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top