Home / Software / Computer programming / Writing multiple text to a text file
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: Writing multiple text to a text file  (Read 546 times)
Little Marine
Topic Starter
Rookie



Posts: 44


« on: November 20, 2009, 04:55:30 AM »

Hello, I am trying to write multiply text from textboxes. I am using this code for a single textbox. Can someone help me to modify this code to write from multiply textboxes.  Thank you.
Dim FILE_NAME As String = "C:\ test2.txt"
If System.IO.File.Exists(FILE_NAME) Then
objWriter.Write(Textbox1.Text)
objWriter.Close()
MsgBox("Text written to file")
Else
    MsgBox("File doesn't exist")
End if
IP logged
Linux711
Adviser



Thanked: 43
Posts: 814

Certifications: List
Computer: Specs
Experience: Experienced
OS: Windows XP

Programming Blog 1
« Reply #1 on: November 21, 2009, 01:29:41 AM »

Quote
I am trying to write multiply text from textboxes.
. . .
Quote
to write from multiply textboxes.

Do you mean multiple?


If you do then


Can't you just make another textbox and add another line?
Code: [Select]
Dim FILE_NAME As String = "C:\ test2.txt"
If System.IO.File.Exists(FILE_NAME) Then
objWriter.Write(Textbox1.Text)
objWriter.Write(Textbox2.Text)
objWriter.Close()
MsgBox("Text written to file")
Else
    MsgBox("File doesn't exist")
End if


else


Then you must want to multiply it. Just add another textbox and use this code.
Code: [Select]
Dim FILE_NAME As String = "C:\ test2.txt"
If System.IO.File.Exists(FILE_NAME) Then
objWriter.Write(Val(Textbox1.Text) * Val(Textbox2.Text))
objWriter.Close()
MsgBox("Text written to file")
Else
    MsgBox("File doesn't exist")
End if


end if

If I don't have it right then

Could you explain it more clearly?

end if
IP logged

YouTube

"Genius is persistence, not brain power." - Me

"The pointer of a programmer is null; something must set it to love" - Me

mroilfield
Adviser



Thanked: 41
Posts: 952

Experience: Experienced
OS: Windows XP



1 1
« Reply #2 on: November 21, 2009, 02:08:01 AM »

end if

If I don't have it right then

Could you explain it more clearly?

end if

What's with the "end if"
IP logged

You can't fix Stupid!!!
Linux711
Adviser



Thanked: 43
Posts: 814

Certifications: List
Computer: Specs
Experience: Experienced
OS: Windows XP

Programming Blog 1
« Reply #3 on: November 21, 2009, 02:15:38 AM »

I was trying to make the whole thing like a program.
IP logged

YouTube

"Genius is persistence, not brain power." - Me

"The pointer of a programmer is null; something must set it to love" - Me

mroilfield
Adviser



Thanked: 41
Posts: 952

Experience: Experienced
OS: Windows XP



1 1
« Reply #4 on: November 21, 2009, 03:05:52 AM »

I was trying to make the whole thing like a program.

Why not just give a straight answer instead so that there is less chance for confusion?
IP logged

You can't fix Stupid!!!
Little Marine
Topic Starter
Rookie



Posts: 44


« Reply #5 on: November 23, 2009, 05:00:31 AM »

Thanks all who replied. My problem is solved
IP logged
Pages: [1] - (Top) Print 
Home / Software / Computer programming / Writing multiple text to a text file « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.087 seconds with 20 queries.