-
January 11th, 2006, 12:58 AM
#1
Changeing the color of a button in a text field
in my program there is a section for credit there are fields like amount ,amt paid ,amt owed if the amount owed if greater than 0 i would like for it to turn a button red so it will show if the person owes money thanks for any help
-
January 11th, 2006, 01:10 AM
#2
Re: Changeing the color of a button in a text field
Set your Button's Style to Graphical, then set it's background color property to red
-
January 11th, 2006, 01:19 AM
#3
Re: Changeing the color of a button in a text field
yes i know that what i was trying to do the button is normaly vb gray if a amount goes into the owed field it will automaticaly change the color to red thanks again for the help
-
January 11th, 2006, 01:29 AM
#4
Re: Changeing the color of a button in a text field
Now, I'm not with you
You want to change the button's color, right....
Now include the code to set the style to graphical and backcolor of the button to red in the txtAmountOwed_Change event.
Or am I understanding you wrong¿
-
January 11th, 2006, 11:59 PM
#5
Re: Changeing the color of a button in a text field
this is the code for the credit text field
Code:
Private Sub pcredit_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
ccity.SetFocus
End If
SaveCurrentRecord
End Sub
i know i need to add something like
if pcredit is > 1 then Command1.BackColor = vbRed
does this help any
-
January 12th, 2006, 12:37 AM
#6
Re: Changeing the color of a button in a text field
Here is a quick sample.
Code:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
If Val(Text1.Text) > 0 Then Command1.BackColor = RGB(250, 0, 0)
End If
End Sub
Last edited by peejavery; January 12th, 2006 at 12:40 AM.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
January 12th, 2006, 08:54 PM
#7
Re: Changeing the color of a button in a text field
ok thank you this code works
Code:
Private Sub pcredit_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Val(pcredit.Text) > 0 Then Command75.BackColor = vbred
preturn.SetFocus
End If
End Sub
now my question about this is
my program allows you to enter in several records and has a next and back button to scroll through the records how can i keep the button red and turn it back gray when you go to a record that has a 0 balance in it
-
January 12th, 2006, 11:52 PM
#8
Re: Changeing the color of a button in a text field
EDIT: Create a function that is called when onkeypress is triggered on each of the input boxes. Below is an example. You can even use element arrays instead of naming each text input.
Code:
Dim tot as integer
Private Sub checktotal()
tot = Text1.Text
tot = tot + Text2.Text
tot = tot + Text3.Text
tot = tot + Text4.Text
If tot > 0 Then Command1.BackColor = RGB(250, 0, 0)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
call checktotal()
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
call checktotal()
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
call checktotal()
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
call checktotal()
End Sub
Last edited by peejavery; January 13th, 2006 at 12:18 AM.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
January 13th, 2006, 12:40 AM
#9
Re: Changeing the color of a button in a text field
i got it to work thanks guys this is the commands i use
Code:
If Val(ppower.Text) > 0 Then Command10.BackColor = vbBlue Else Command10.BackColor = &H8000000F
If Val(pcredit.Text) > 0 Then Command11.BackColor = vbBlue Else Command11.BackColor = &H8000000F
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
|