?
Solved

variable in sentence

Posted on 2003-03-23
6
Medium Priority
?
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this post we will learn different types of Android Layout and some basics of an Android App.
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

752 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