Well that ill be because if the TextBox doesn't have more than 6 characters it will not work as when I began to learn VB I asked for this and got this error was because of that!
well thanks for ur helping spirit
so how i can i do like theres a text box in that i have selected some paths to load on line 1 a path on the second another path so and every path i to be used by an button so how can i do to load the 1st button 1st line of the text box (that means its select a path) and 2nd button select second line and so on
So as the image says how can i write to that txtfile which is added by the Vb it self so the advantage would be that nobody could see the file
plz help need serious one
Last edited by watson123; Feb 8th, 2010 at 08:51 AM.
Reason: wrong spelling
Adding an empty textfile to your project is pointless. Usually such text files contain some side notes or documentation or something else and their contents are not modified within the code.
If you simply want to create a textfile then just use IO.FileStream:
Code:
Using sw As New IO.StreamWriter("C:\test.txt")
sw.WriteLine("123456 Some text")
sw.Flush()
sw.Close()
End Using
To delete first 6 characters from a textfile do:
vb.net Code:
' Will delete the first 6 bytes from the file "C:\Test.txt"
Dim BytesToDelete As Integer = 6
Try
Dim fs As New IO.FileStream("C:\Test.txt", IO.FileMode.Open, IO.FileAccess.ReadWrite, IO.FileShare.None)
Dim srcBuff(CInt(fs.Length - 1)) As Byte
fs.Read(srcBuff, 0, CInt(fs.Length))
Dim dstBuff(srcBuff.Length - BytesToDelete - 1) As Byte
ok no problems if the text file is not editable
is there anyway else by which we can save the text file but it should not be visible to the user
and can i replace those 6 characters from the textbox or
i think we could delete those and add something to the start of every line that would be more easier
Though I cannot imagine why would you want one, but you can add a textfile as a resource to your .exe.
Go to menu Project / Properties / Resources tab
From the 'Add resouce' dropdown select Add new text file.
Bear in mind that you wouldn't be able to modify the contents of your text file once it's been added as a resource.
can i replace those 6 characters from the textbox or
i think we could delete those and add something to the start of every line that would be more easier???
Replacing is easier (you don't have to change the length of a file).
By the way, can you tell us what EXACTLY you are trying to achieve? Knowing this it'd be easier to help you.
well i'm looking for the code to replace those 6 characters from the textbox
and add something else more than 6 or less and do this process to everyline
and how can i select the 2nd line only and add something
for example
we use
Code:
TextBox1.Text = "Example"
So how can i select the second line and replace anything
I Tried
Code:
Textbox1.Text.Lines(3) = "Example" ' not working
Textbox1.Lines(2) = "This is an example" ' not working
This code does not delete anything. Split function just splits your string into several using comma as a delimeter. The resulting array (sText) will contain all parts of the text.
For example:
vb.net Code:
Dim Text As String = "ab, cd, ef, gh"
Dim sText() As String = Split(Text, ",")
After this, your sText array will have the following members:
sText(0) = "ab"
sText(1) = "cd"
sText(2) = "ef"
sText(3) = "gh"
For Each line As String In TBox.Lines '<- array created here
Dim Text As String = line
Dim sText() As String = Split(Text, ",")
TextBox1.Text = TextBox1.Text & vbCrLf & sText(1)
Thanks For ur Help
I just Wanted to know
How to search for for a name like if in the textbox contains ".at3"
Then it could show me the line number or something like that??
And how to search for a word
Last edited by watson123; Feb 14th, 2010 at 01:03 AM.
For Each line As String In TextBox1.Lines '<- array created here
Dim f As String = line
Dim s As String = f.Substring(f.LastIndexOf(".") + 1)
If s = "at3" Then
TextBox2.Text = Textbox2.Text + vbCrLf + line
End If
If u want any help in this topic just reply here
thanks to all
Hey PLz tell me can i edit or see the hex of any file in vb????
A StreamReader returns the ASCII values of any file that's read. Granted, if you read more than a text file you'll probably get mostly garbled data that has no ASCII equivalent.
Anyone i don't want to edit it i just want to see the first word
The "first word" is very...vague. First word of what? The first word of the line you're reading, or the name of the file you're reading? It could be anything that you're asking.
As for adding dummy data to the end of the file, you have to manipulate the file in such a way to read to the end, then start writing at the end of the file. One more note, don't bump your topic within 4 hours on the same day. It clogs up the forums. It's generally given that you should wait 24 hours before "bump"ing your post.
ok sorry formlesstree4
the "first word" Means the first offset in the hex editing where the extension is given
And has anyone succeded in Eugene Pavlov Hex Editor Ocx??? if yes plz tell me how did u open a file with it??? http://www.codeproject.com/KB/edit/hexeditor.aspx
i have some codes here it works fine but if the text file is long and big it does not respond and after showing not responding for some time it works I think it keep processing the files
So i wanted to have a progress bar and it would work properly
its a program for removing some words (LBA) from a file list which is seperated by comma so as i said if the file list is long it hangs so i want some tips from you i wanted to have a progress bar
I think if i count the number of lines and then do something like when it has done 1% of the total lines it would increase value by 1
And it does not show not responding
here are my codes
Code:
For Each line As String In TBox.Lines '<- array created here
Dim Text As String = line
Dim sText() As String = Split(Text, ",")
TextBox1.Text = TextBox1.Text & vbCrLf & sText(1)
Next
Tbox.Text = TextBox1.Text
TextBox1.Text = Nothing
Last edited by watson123; Feb 16th, 2010 at 08:26 AM.
It's an equivalent of the code you posted, but mine reports a progress to a progressbar.
Drop a progressbar (named ProgressBar1) onto a form and uncomment:
ProgressBar1.Value = Progress (see comments).