Loop question

Pyro

Too busy to comment
Local time
Tomorrow, 05:53
Joined
Apr 2, 2009
Messages
127
Hi,

I have the following code:

Code:
Dim X As Long
 
X = Len(Me.txtProduct_Temp_Req) -1

If Not IsNumeric(Right(Me.txtProduct_Temp_Req, 1)) Then
    Me.txtProduct_Temp_Req = Left(Me.txtProduct_Temp_Req, X)
 
Else
    Me.txtProduct_Temp_Req = Me.txtProduct_Temp_Req & "°C"

End If

I would like to run this as a loop to chop off any character that is not a number and then tack on "°C", but i haven't really come across the need for anything like this until now.

I have tried a few ideas but they have mostly just crashed access... any ideas?
 
It seems as though my perseverance has paid off:

Code:
Do Until Right(Me.txtProduct_Temp_Req, 2) = "°C"
 
Dim X As Integer
 
X = Len(Me.txtProduct_Temp_Req) - 1
 
If Not IsNumeric(Right(Me.txtProduct_Temp_Req, 1)) Then
    Me.txtProduct_Temp_Req = Left(Me.txtProduct_Temp_Req, X)
     
Else
    Me.txtProduct_Temp_Req = Me.txtProduct_Temp_Req & "°C"
 
End If
 
Loop

...seems to work.

Thanks anyway! :) :)
 
to CHOP OFF the last chars in the string, instead of replacing all non numbers completely, maybe try...
PHP:
Dim X As string
 
X = Me.txtProduct_Temp_Req 

do until isnumeric(right(x, 1)) = false

   x = left(x, (len(x) - 1)

loop

    Me.txtProduct_Temp_Req = x & "°C"
 

Users who are viewing this thread

Back
Top Bottom