Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 04-24-2016, 10:46 AM
Mgeorge Mgeorge is offline
Junior Member
 
Join Date: 04-24-16
Posts: 3
iTrader: 0 / 0%
Help with If and Then Statement VB

Can someone assist me with writing a statement in VB? Thanks in advance

Marquita
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 04-25-2016, 02:15 AM
Dan Williamson Dan Williamson is offline
The Controversial Coder
 
Join Date: 05-01-06
Location: Manchester; UK
Posts: 2,710
iTrader: 0 / 0%
Sure:

Code:
Dim i as String = "Hello" If i = "Hello" Then Console.WriteLine("Hi")
It's not very helpful, but neither was your question you need to give us more information.
 
Reply With Quote
  #3  
Old 04-25-2016, 06:36 AM
Mgeorge Mgeorge is offline
Junior Member
 
Join Date: 04-24-16
Posts: 3
iTrader: 0 / 0%
Quote:
Originally Posted by Dan Williamson View Post
Sure:

Code:
Dim i as String = "Hello" If i = "Hello" Then Console.WriteLine("Hi")
It's not very helpful, but neither was your question you need to give us more information.
Sorry about that, I'm new to the forum world

Can you assist me in figuring out why I cant get a number in the percentage?

This is problem:
The manager of Willow Springs Health Club wants a program that allows her to enter the number of calories and grams of fat contained in a specific food. The program should calculate and display two values: the food's fat calories and its fat percentage. The fat are the number of calories attributed to fat and are calculated by multiplying the food's fat grams by the number 9; this is because each gram of fat contains nine calories. the fat percentage is the ratio of the food's fat calories to its total calories and then by multiplying the result by 100. The fat percentage should be displayed with zero decimal places. Create a Visual Basic Window application.

'calculates and displays Fat Calories and Fat Percentage

Dim intgrams As Integer
Dim decfatcalories As Decimal
Dim decfatpercentage As Decimal
Dim deccalories As Decimal

'assign variables
Decimal.TryParse(lblFatCalories.Text, decfatcalories)
Decimal.TryParse(lblFatPercentage.Text, decfatpercentage)
Decimal.TryParse(txtCal.Text, deccalories)
Integer.TryParse(txtGrams.Text, intgrams)

'calculate Results
lblFatCalories.Text = (intgrams * 9).ToString
lblFatPercentage.Text = ((decfatcalories / deccalories) * 100).ToString
Attached Thumbnails
Click image for larger version

Name:	results.PNG
Views:	31
Size:	4.9 KB
ID:	18535  
 
Reply With Quote
  #4  
Old 05-23-2016, 05:27 AM
blizzardofozz blizzardofozz is offline
Junior Member
 
Join Date: 05-23-16
Posts: 22
iTrader: 0 / 0%
Have you tried to debug? Most of the variables are not declared in your code.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
missing ; before statement scifirocket Coding Forum 5 10-10-2010 12:46 PM
php if statement help aylee Coding Forum 1 06-14-2007 06:46 AM
PHP Redirect within IF statement Pipeline-Webdesign Coding Forum 7 06-17-2004 10:29 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 11:04 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC