Form Textbox not showing correct value

Seandobson2402

New Member
Joined
Feb 9, 2018
Messages
23
Hi All,

I have the below routinefor my userform to show a Points System (1.1, 1.2, 2.1, 2.2, 3 & 4)

I seem to be having trouble with the line - If CatPoints < 85 Then SohoCat = 2.2 Else SohoCat = 3.. My form brings up 2 as the Value instead of 2.2. I have no idea why.

Code:
Private Sub PointsCat()
    Dim SohoCat As Long
    Dim VergeCoeff As Long, FootwayCoeff As Long
    Dim CatPoints As Long
    Dim AllCivilsEntered As Boolean
    'linear equation coefficients for cat calculation
    VergeCoeff = 1
    FootwayCoeff = 5
    
    With Me
    
        'set the colours to red if not value not entered, off white otherwise
        If .cbVergeM.Value = "" Then .cbVergeM.BackColor = &HFF& Else .cbVergeM.BackColor = &H80000005
        If .cbFootwayM.Value = "" Then .cbFootwayM.BackColor = &HFF& Else .cbFootwayM.BackColor = &H80000005
        If .cbCarriagewayM.Value = "" Then .cbCarriagewayM.BackColor = &HFF& Else .cbCarriagewayM.BackColor = &H80000005
        If .cbSpecialistPavingM.Value = "" Then .cbSpecialistPavingM.BackColor = &HFF& Else .cbSpecialistPavingM.BackColor = &H80000005
        
        'determine if all civils have been entered
        AllCivilsEntered = .cbVergeM.Value <> "" And .cbFootwayM.Value <> "" And .cbCarriagewayM.Value <> "" And .cbSpecialistPavingM.Value <> ""
        
        If AllCivilsEntered Then
            'initialise
            CatPoints = 0
            'first condition
            If .cbSpecialistPavingM.Value = 1 Or .cbSpecialistPavingM.Value = 2 Then CatPoints = 20
            'continue with second condition (equation)
            CatPoints = CatPoints + VergeCoeff * .cbVergeM.Value + FootwayCoeff * .cbFootwayM.Value
            'this takes precedence
            If CatPoints < 85 Then SohoCat = 2.2 Else SohoCat = 3
            If .cbCarriagewayM.Value <> 0 Or .cbSpecialistPavingM.Value > 2 Then SohoCat = 3
            'update the points label... this is made visible/invisible by the tests in the calling routine
            .lPoints.Caption = "Points= " & CatPoints
            .tSoCatResult.BackColor = &H80000005
            .tSoCatResult.Value = SohoCat
        Else
            'set the colours to red if value not entered, off white otherwise
            If .cbVergeM.Value = "" Then .cbVergeM.BackColor = &HFF& Else .cbVergeM.BackColor = &H80000005
            If .cbFootwayM.Value = "" Then .cbFootwayM.BackColor = &HFF& Else .cbFootwayM.BackColor = &H80000005
            If .cbCarriagewayM.Value = "" Then .cbCarriagewayM.BackColor = &HFF& Else .cbCarriagewayM.BackColor = &H80000005
            If .cbSpecialistPavingM.Value = "" Then .cbSpecialistPavingM.BackColor = &HFF& Else .cbSpecialistPavingM.BackColor = &H80000005
            .tSoCatResult.BackColor = &HFF&
            .tSoCatResult.Value = "N/A"
        End If
        
    End With
    
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top