0

hello everybody

I am new to this forum. i got a doubt. i working on a small project. the thing is my Hosp no should be in the format 123456R. Now there are old patient with the following the hospital number 12345R. In this case i want a 0 to be added in the prefix. for 012345R. In both the cases I want R to be added automatically. Since an alphabet is a there i am using a text box but i don't know how to do a prefix or suffix

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by QVeen72
0
if right(ucase(text1.text), 1) <> "R" then
     text1.text = text1.text & "R"
else
     text1.text = "0" & text1.text
end if

...

0

Hi,

Check The Length and Prefix a 0

If Right(UCase(Text1.Text), 1) <> "R" then
    Text1.Text = Text1.Text & "R"
End If
If Len(Text1.Text)  < 7 Then
    Text1.Text = String((7-Len(Text1.Text)),"0") & Text1.Text
    'Pads with zeros to make 7 Chars 
End If

Regards
Veena

0

thanks for the post

hi qveen the syntax works fine for the first part, that is adding the "r"
but the problem with the second half is that it is not adding zero to the prefix but it is just making it zero

0

Hi,

Try This :

If Right(UCase(Text1.Text), 1) <> "R" then
      Text1.Text = Text1.Text & "R"
 End If
 Text1.Text = Right( "0000000" & Text1.Text,7)

Regards
Veena

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.