?
Solved

variable in sentence

Posted on 2003-03-23
6
Medium Priority
?
247 Views
Last Modified: 2010-05-18
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
Comment
Question by:EmurphY
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
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

by:Jacamar
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

by:itcprog
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Accepted Solution

by:
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

by:EmurphY
ID: 8204822
Thanks for the help.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8207021
What was wrong with the other replies?

mlmcc
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Introduction to Processes

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question