LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling a Sub passing Textbox name

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate Textbox value based on another textbox value.doc Tdungate Excel Discussion (Misc queries) 1 February 12th 09 07:11 PM
Calculate Textbox value based on another textbox value Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:03 PM
calling a C++ program from Excel 2000 and passing a result from C++ back to an excel spreadsheet ellis kurland Excel Discussion (Misc queries) 3 August 15th 05 04:10 PM
passing strings vba man Excel Programming 0 December 21st 03 07:12 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 01:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"