Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all, I am new to this forum and still somewhat green in VBA but
have quite a bit of Delphi and C++ programming experience so that i what makes my problem even more frustrating. I have created a sub that will make changes to a textbox's propertie based on the value the user entered compared to the value of a label. I would like to be able to pass to this sub the names of the textbo and the label that it should use for it's testing and changes. Here is what I have written so far, keep in mind this doesn't work: Sub TextBoxChanges(thebox As TextBox, thelbl As Label) thebox.BackColor = RGB(255, 255, 255) thebox.ForeColor = RGB(0, 0, 0) If Val(thebox.Text) = Val(thelbl.Caption) Then thebox.BackColor = RGB(0, 100, 0) thebox.ForeColor = RGB(255, 255, 255) ElseIf Val(thebox.Text) = Val(thelbl.Caption) - 1 Then thebox.BackColor = RGB(255, 0, 50) thebox.ForeColor = RGB(255, 255, 255) ElseIf Val(txt_h1.Text) = Val(thelbl.Caption) - 2 Then thebox.BackColor = RGB(255, 255, 0) thebox.ForeColor = RGB(0, 0, 0) ElseIf Val(txt_h1.Text) = Val(thelbl.Caption) + 1 Then thebox.BackColor = RGB(165, 165, 165) thebox.ForeColor = RGB(0, 0, 0) End If End Sub Private Sub txt_h1_Change() Call TextBoxChanges(txt_h1, lbl_p1) End Sub I have 18 text boxes so I would like to have an onChange event for eac textbox so that I can save some code. Any help would be apreciated please post back if you need more information. Thanks -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calculate Textbox value based on another textbox value.doc | Excel Discussion (Misc queries) | |||
Calculate Textbox value based on another textbox value | Excel Discussion (Misc queries) | |||
calling a C++ program from Excel 2000 and passing a result from C++ back to an excel spreadsheet | Excel Discussion (Misc queries) | |||
passing strings | Excel Programming | |||
UserForm TextBox to ActiveSheet TextBox over 256 characters | Excel Programming |