Re: Text box format VBA

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Harald Staff (innocent_at_enron.invalid)
Date: 02/01/04


Date: Sun, 1 Feb 2004 11:51:24 +0100


"gregork" <gregork@paradise.net.nz> wrote in message
news:t03Tb.20011$ws.2674481@news02.tsnz.net...
> I want to format back colour based on text in a textbox. i.e. If
> textbox27 text="fail" then
> TextBox27.BackColor = &HC0C0FF.

You are very close:

If TextBox27.Text = "fail" Then
    TextBox27.BackColor = "&HC0C0FF"
Else
    TextBox27.BackColor = "&HFFFFFF"
End If

But consider uppercase, mixed case, part entries, trailing spaces...
If InStr(Trim$(LCase$(TextBox27.Text)), "fail") > 0 Then
reacts also on entry " You FAILED madam"

--
HTH. Best wishes Harald
Followup to newsgroup only please.


Relevant Pages

  • E-Mail
    ... Excuse me for not finding this newsgroup sooner as the question i'm about to ... How do i format a textbox ...
    (microsoft.public.access.forms)
  • Re: Use TextBox Text As Function Name!
    ... the text in the TextBox changes to "<the name of the ... > OptionButton that was checked just before the selection change>2<the ... You have some design issues here. ... using the most common format. ...
    (microsoft.public.vb.general.discussion)
  • Re: Newbie question on formatting a field in table design
    ... Each department field is set to the default format ... multiplies the number entered by 100 and adds the "%" sign. ... right of the textbox, then store the number that way and do the ... normalized table design would convert your 11 ...
    (comp.databases.ms-access)
  • Re: Custom Cell Format problem
    ... I am having trouble with this "raw" TextBox. ... when I paste the contents of the UserForm into a new row on the sheet ... I have raw data in the format of 3 numbers, ...
    (microsoft.public.excel.programming)
  • Re: unicode textbox problem
    ... I get the data in the above format from SQL server. ... If I move the same data into an asp:textbox, or an html input textbox, I ... But I need this to show the Chinese characters. ...
    (microsoft.public.dotnet.languages.csharp)