|
-
Jan 31st, 2000, 09:10 PM
#1
Thread Starter
Junior Member
my objective is to change the textbox backcolor to green, if empty.
'please execute & find the answer:-
'it has 1 command button cmdadd tabindex 3)
' 3 text boxes - txtcandid(ti 0),
' txtappliedfor(ti 1),
' txtindustryid(ti 2)
'another command button cmdindustryhelp(tabstop false) next to industryid.
'
' form looks like this:-
'--------------------------------------------
'| |
'| txtCandid
'| txtappliedfor
'| txtindustryid cmdindustryhelp
'|
'| cmdadd
'--------------------------------------------
Private Sub cmdAdd_Click()
txtAppliedfor.SetFocus
End Sub
Private Sub cmdIndustryIdHelp_Click()
MsgBox "hello"
txtIndustryId.SetFocus
End Sub
Private Sub Form_Load()
txtCandId.Enabled = False
End Sub
Private Sub txtAppliedfor_GotFocus()
txtAppliedfor.BackColor = vbWhite
End Sub
Private Sub txtAppliedfor_Validate(Cancel As Boolean)
If txtAppliedfor.Text = "" Then
txtAppliedfor.BackColor = vbGreen
End If
End Sub
can u help?
friendly,
jey.
-
Jan 31st, 2000, 10:23 PM
#2
Lively Member
The code that you have worked fine for me. You may have spaces in your textboxes and just don't realize it. Try using the Trim() function like this:
Code:
Private Sub txtAppliedfor_Validate(Cancel As Boolean)
If Trim(txtAppliedfor.Text) = "" Then
txtAppliedfor.BackColor = vbGreen
End If
End Sub
-
Feb 4th, 2000, 01:41 PM
#3
New Member
Hi Jeyashree,
How are you.... Here come the solution for your query....
''''''''''''''''''''''''''''''''''''''''''''
' No of TextBox's - 3 ( control array)
''''''''''''''''''''''''''''''''''''''''''''
' IfVirus(0)
' IfVirus(1)
' IfVirus(2)
''''''''''''''''''''''''''''''''''''''''''''
' No of Command Buttons - 2
''''''''''''''''''''''''''''''''''''''''''''
' cmdAdd
' cmdIndustryIdHelp
''''''''''''''''''''''''''''''''''''''''''''
Private Sub cmdAdd_Click()
IfVirus(1).SetFocus
End Sub
Private Sub cmdIndustryIdHelp_Click()
IfVirus(2).SetFocus
End Sub
Private Sub Form_Load()
For i = 0 To IfVirus.Count - 1
If Len(Trim(IfVirus(i))) = 0 Then
IfVirus(i).BackColor = vbGreen
Else
IfVirus(i).BackColor = vbWhite
End If
Next
End Sub
Private Sub IfVirus_Change(Index As Integer)
If Len(Trim(IfVirus(Index))) = 0 Then
IfVirus(Index).BackColor = vbGreen
Else
IfVirus(Index).BackColor = vbWhite
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''
Yours
Murali
[email protected]
[email protected]
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
|