Solved

# variable in sentence

Posted on 2003-03-23
Medium Priority
247 Views
I'm only starting at this so it might be a stupid question but

I need a label(or txt box) on my form that reads "The patients body mass index is XXX so according to obesity levels they are underweight/normal/obese".

How do I put the numeric variable in the sentence?

The program is in VB
0
Question by:EmurphY

LVL 101

Expert Comment

ID: 8192429
If (Me.txtBodyMass.Text < NormalLow) then
strBodyType = "underweight"
Elseif (Me.txtBodyMass.Text <+ NormalHigh) then
strBodyType = "normal"
Else
strBodyType = "obese"
End If

Me.lbl1.Caption = "The patients body mass index is " & Me.txtBodyMass.Text & "XXX so according to obesity levels they are " & strBodyType

mlmcc
0

LVL 2

Expert Comment

ID: 8192498
dim sgWeight as single
dim stType as string
sgWeight = csng(txtBodyMass.text)
if stWeight< Normal then stType = "Underweight"
if stWeight>=Normal then stType = "normal"
if stWeight>=High then stType = "Obese"
Label1.caption = "Body mass index = " & stWeight & ", and Patient is " & stType
0

Expert Comment

ID: 8192783
For a Label:
label1.caption = "The patients body mass index is " & cstr(BMI_Amount) & " so according to obesity levels they are "
if BMI_Amount <= underweight_Amount then label1.caption = label1.caption & "underweight."

if BMI_Amount = Normal_Amount then label1.caption = label1.caption & "Normal."

if BMI_Amount => overweight_Amount then label1.caption = label1.caption & "Obese."

To use a text box change label1.caption to text1.text

The Cstr command converts a number into a string which can then be added to any other string.
0

LVL 30

Accepted Solution

Mayank S earned 150 total points
ID: 8192922
Numeri variable can be converted into a string by the use of the CStr () function.

Dim Temp As String

If patientMass < 50 ' or what-ever the limit for it is
Temp = "underweight"
Else
If patientMass < 80 ' or what-ever the limit for it is
Temp = "normal"
Else
Temp = "obese"
End If
End If

MyTextbox.Text = "The patients' body mass index is " & CStr (patientMass) & ", so according to obesity levels, they are " & temp & ". "

Hope that helps!

Mayank.
0

Author Comment

ID: 8204822
Thanks for the help.
0

LVL 101

Expert Comment

ID: 8207021
What was wrong with the other replies?

mlmcc
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …