|
-
Feb 5th, 2007, 01:02 PM
#1
Thread Starter
Lively Member
Variable Types
As String would be a single line of text, what would be the variable type for multiple lines of text?
-
Feb 5th, 2007, 01:20 PM
#2
Re: Variable Types
You can store many lines in a string
"The dark side clouds everything. Impossible to see the future is."
-
Feb 5th, 2007, 02:34 PM
#3
Re: Variable Types
 Originally Posted by smart_phil_dude1
As String would be a single line of text, what would be the variable type for multiple lines of text?
This isn't true... A string is a string, it doesn't matter how many lines it contains. You can add lines to a string by inserting Chr(10), Chr(13), ControlChars.NewLine... Some thing lke this:
VB Code:
Dim str As String = "This is 1st line" & Chr(10) & "This is 2nd line"
-
Feb 5th, 2007, 02:44 PM
#4
Fanatic Member
Re: Variable Types
Well, a string is really just an array of chars and a new line is just a combination of chars, so thus you can have any number of "lines" in a string variable.
-
Feb 12th, 2007, 08:10 PM
#5
Thread Starter
Lively Member
Re: Variable Types
well, i am programming an application that reads off multiple lines on a txt file, but it won't read multiple lines, it only works if one line is written.
-
Feb 12th, 2007, 08:23 PM
#6
Re: Variable Types
 Originally Posted by smart_phil_dude1
well, i am programming an application that reads off multiple lines on a txt file, but it won't read multiple lines, it only works if one line is written.
How do you read the file? And what version of VB are you coding with?
-
Feb 12th, 2007, 08:40 PM
#7
Re: Variable Types
If you are reading one line at a time then you're only reading part of the string that the file contains at a time. You can read the whole file into a single string:
VB Code:
Dim contents As String = IO.File.ReadAllText("file path here")
or you can read the contents of the file and break it up on the line breaks:
VB Code:
Dim lines As String() = IO.File.ReadAllLines("file path here")
There are other ways to read the file too but they all amount to the same thing. You can read the whole file into a single string if you want. If you read a line at a time then it's YOU who are removing the line breaks and splitting the file contents into pieces. If you don't need the individual lines then don't break the file up into lines. If you do need the lines then you can either read and use one line at a time or do as I did above and use a String array.
-
Feb 18th, 2007, 01:32 PM
#8
Thread Starter
Lively Member
Re: Variable Types
i set it up into different lines, just like using your second example...
-
Feb 18th, 2007, 05:30 PM
#9
Re: Variable Types
Sorry, I'm not sure whether that last post constituted a question or not.
-
Feb 23rd, 2007, 12:28 PM
#10
Thread Starter
Lively Member
Re: Variable Types
well i tried what you explained and i still get an error
-
Feb 23rd, 2007, 06:02 PM
#11
Re: Variable Types
And how can we possibly help fix it if you don't tell us what it is?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|