Join 149,936 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,445 people online right now. Registration is fast and FREE... Join Now!
Will try this post again, everything went blank on me.
I'm retired and thought I'd like to learn vs 2008 Express as a hobby. I'm running Vista Home Premiun.
This is my first post and hope not to bug you people too much.
Thanks for all your help I'm about to recieve
wes
CODE
Private Sub openChequeBook()
Dim mo As String Dim a As Single Dim p As String Dim cbb As Single Dim d As Decimal Dim fn As String = "C:\\ChequeBook\purchases.txt"
If System.IO.File.Exists(fn) = True Then Dim objReader As New System.IO.StreamReader(fn) Dim sp As String, text As String, bigtex As String sp = " " ''20 spaces text = "" bigtex = ""
Do While objReader.Peek() <> -1 mo = objReader.ReadLine a = objReader.ReadLine cbb = objReader.ReadLine p = objReader.ReadLine
text = mo & sp text = text.Substring(0, 13) bigtex = bigtex & text text = String.Format("{0:c}", a) & sp text = text.Substring(0, 9) bigtex = bigtex & text text = String.Format("{0:c}", cbb) & sp text = text.Substring(0, 11) bigtex = bigtex & text text = p & sp text = text.Substring(0, 19) bigtex = bigtex & text & vbNewLine Loop objReader.Close() TextBox1.Text = bigtex Else MsgBox("File Does Not Exist") End If
End Sub
EDIT: Please, next time, use code tags, like so ( ) Thanks
This post has been edited by PsychoCoder: 24 Jan, 2008 - 12:50 PM
You could accomplish that with a simple If statement, like so
CODE
If value < 0 Then Label1.ForeColor = Color.Red Label1.Text = "Your Text Here" Else 'All is normal End If
Thanks for the help,, but I get to many errors.
Sorry for being so ignorant. wes
CODE
text = String.Format("{0:c}", cbb) & sp ''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' this turns the whole text box to red ' negative balances are show in brackets with a minus sign If text.Substring(0, 1) = "(" Then TextBox1.ForeColor = Color.Red Else TextBox1.ForeColor = Color.Black End If ''''''''''''''''''''''''''''''''''''''''''''''''''''''''' text = text.Substring(0, 11) bigtex = bigtex & text
If d < 0 then textbox1.color = color.red else if d>= 0 then textbox1.color = color.black end if textbow.1.text = d
Sorry that doesn't work either
it says that " color is not a member System.Windows.Form.Textbox" and that text is not a member of double.
Do I have to declare my variables as double, they;er declared as Single now
wes
[''''''''''''''''''''''''''''''''''''''''''''''''''''' text = String.Format("{0:c}", cbb) & sp value = cbb If value < 0 Then Label1.ForeColor = Color.Red Label1.Text = text Else 'All is normal End If ''''''''''''''''''''''''''''''''''''''''''''''''''''''''' text = text.Substring(0, 11) bigtex = bigtex & text ]
If d < 0 then textbox1.color = color.red else if d>= 0 then textbox1.color = color.black end if textbow.1.text = d
Sorry that doesn't work either
it says that " color is not a member System.Windows.Form.Textbox" and that text is not a member of double.
No, that was just me making a dumbass mistake
CODE
If d < 0 then d.tostring d.color = color.red else if d>= 0 then d.tostring d.color = color.red end if textbow.1.text = d
Sorry i messed that up, I dont have VS on the computer im using right now and i cant get it. this in turn means that all this code has to be tested in my head and my head is a very scary place.
If d < 0 then textbox1.color = color.red else if d>= 0 then textbox1.color = color.black end if textbow.1.text = d
Sorry that doesn't work either
it says that " color is not a member System.Windows.Form.Textbox" and that text is not a member of double.
No, that was just me making a dumbass mistake
CODE
If d < 0 then d.tostring d.color = color.red else if d>= 0 then d.tostring d.color = color.red end if textbow.1.text = d
Sorry i messed that up, I dont have VS on the computer im using right now and i cant get it. this in turn means that all this code has to be tested in my head and my head is a very scary place.
The error I get now is that Color is not a member of Decimal
Boy!! I didn't think that this would cause such a big problem ... Sorry everybody.
If d < 0 then textbox1.color = color.red else if d>= 0 then textbox1.color = color.black end if textbow.1.text = d
Sorry that doesn't work either
it says that " color is not a member System.Windows.Form.Textbox" and that text is not a member of double.
No, that was just me making a dumbass mistake
CODE
If d < 0 then d.tostring d.color = color.red else if d>= 0 then d.tostring d.color = color.red end if textbow.1.text = d
Sorry i messed that up, I dont have VS on the computer im using right now and i cant get it. this in turn means that all this code has to be tested in my head and my head is a very scary place.
The error I get now is that Color is not a member of Decimal
Boy!! I didn't think that this would cause such a big problem ... Sorry everybody.
Thanks for all your help .
I'll keep trying
wes
Since I use a substring to place the text in the text box is there any way that I can change the color of a substring since the negative numbers are in brackets, I thought ( this getting dangerous - me thinking ) I would try just changing the color of the substring, or am I out in left field some where lost again wes
CODE
If cbb < 0 Then text = text.Substring(0, 10) text.Forecolor = Color.Red Else text = text.Substring(0, 9) text.Forecolor = Color.Black End If
The error I get is that Forecolor is not a member of string.
How can I change this
Thanks for all your Help wes
This post has been edited by PsychoCoder: 25 Jan, 2008 - 08:28 AM
You're trying to set the ForeColor of a string, which isn't going to happen as there is no ForeColor Property for the String class. You should be setting the ForeColor of the textbox the text will be displayed in
You're trying to set the ForeColor of a string, which isn't going to happen as there is no ForeColor Property for the String class. You should be setting the ForeColor of the textbox the text will be displayed in
I don't want the whole text box in red, just my negative number which is in brackets.
This programing is getting more FRUSTRATED by the minute.
I want the text changed not the text box, hope somebody makes a better programing language soon.
I'll keep struggling away, Thanks For all your efforts
The problem here is that you don't seem to understand that setting the ForeColor property of a textbox only affects the color of the text as it is displayed in the TextBox, NOT the textbox itself.
Have you even tried using the solution that everyone here has been trying to help you with?
The BackColor property is used to change the entire TextBox to red, while leaving the text the default color of black.
You can not directly change the color of text, you can only change the way it is displayed in a control.