Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   What is wrong with this Output Statement (http://www.programmingforums.org/showthread.php?t=15021)

kewlgeye Jan 24th, 2008 8:34 AM

What is wrong with this Output Statement
 
I am trying to output a number that is entered into a textbox called adminsundaycpaTextBox.Text. This number is supposed to be entered into a text file called Sundaypm.Text

I had absolutely no idea how to use visual basic 1 month ago, and now I am trying to learn. So here is my code. for the output statement.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click




' Open the file for output.
FileOpen(1, "Sundaypm.txt", OpenMode.Output)
' Close before reopening in another mode.


' Calculate Checkpoint A situation.


adminsundaycpaTextBox.Text = adminsundaycpaTextBox.Text

Write(1)
FileClose(1)
Me.Close()
End Sub


There was not much help online, because most was for older versions of visual basic. I learned this much using the index feature in visual basic. Thank you for your replys.

Sane Jan 24th, 2008 8:50 AM

Re: What is wrong with this Output Statement
 
:

adminsundaycpaTextBox.Text = adminsundaycpaTextBox.Text

That piece of code there does absolutely zip. Nadda. You are telling it to reassign its value to itself. In other words, x = x.

You don't seem to be using the right code for writing files. At least according to this thread. You might want to use the second example ("An example of writing a file").

Edit: Oh, you're using a newer version of VB that doesn't support this? Hmph.
Try Write(adminsundaycpaTextBox.Text).

kewlgeye Jan 25th, 2008 10:46 PM

Re: What is wrong with this Output Statement
 
Edit: Oh, you're using a newer version of VB that doesn't support this? Hmph.
Try Write(adminsundaycpaTextBox.Text).[/quote]


I figured it out, but now I am having a trouble reading from the file and storing the result in a variable so that I can compare it to another. Any ideas on how to read one number from a file and store it into a variable?

Thank you for your reply, I am using a different computer otherwise I would share the solution code that I used.


All times are GMT -5. The time now is 9:13 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC