Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Isolate part of a string 1

Status
Not open for further replies.

skyline666

Programmer
Oct 22, 2007
141
GB
Hi,

I have a command button called cmbCalculate in a form called RiskEstimate, in an Access 2003 Project. On the Click event of this button, I have some code:

Code:
If totalWeighting < 15 Then
    Me.RatingOverall = totalWeighting & " - Low"
    Me.RatingOverall.BackColor = vbYellow
ElseIf totalWeighting < 40 Then
    Me.RatingOverall = totalWeighting & " - Medium"
    Me.RatingOverall.BackColor = 33023
ElseIf totalWeighting >= 40 Then
    Me.RatingOverall = totalWeighting & " - High"
    Me.RatingOverall.BackColor = vbRed
End If
totalWeighting is a variable that holds a calculated number. RatingOverall is a text box that holds the value produced by totalWeighting, and puts on the end of this value if it is a low, medium or high risk.

Depending on this value, the background colour will be a certain colour. This all works. What I need is to have the background colour appear in the text box on the Form_open event of RiskEstimate. I know I need to isolate the number out of the string that is held in RatingOverall, but don't know how. When the value is isolated, I want to be able to then use it to do this:

Code:
If isolatedValue < 15 Then
    Me.RatingOverall.BackColor = vbYellow
ElseIf isolatedValue < 40 Then
    Me.RatingOverall.BackColor = 33023
ElseIf isolatedValue >= 40 Then
    Me.RatingOverall.BackColor = vbRed
End If

Many thanks in advance for your help.

Andrew
 
Val should suit as long as the number you want is at the start of the textbox:

Val(Me.RatingOverall)
 
Hi Remou,

The number is at the start at it worked.

Thanks,

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top