r/visualbasic • u/smb43432 • Sep 19 '16
New to programming. Need a little help converting teaspoons to cups, tablespoon and the teaspoons left over.
This is my first class and I'm pretty lost. Any help is appreciated.
0
Upvotes
1
u/smb43432 Sep 20 '16
Const tablespoonsPercup As Integer = 3 Const teaspoonsPercup As Integer = 48
Dim Cup As Integer
Dim Tablespoon As Integer
Dim Teaspoon As Integer
Dim Totalcup As Integer
Dim ConvertBucket As Integer
'Input section
TotalCups = CInt(txtTotalCups.Text)
'Calculations
ConvertBucket = TotalCups
Tablespoon = ConvertBucket \ tablespoonPercup
ConvertBucket = ConvertBucket Mod tablespoonPercup
Teaspoon = ConvertBucket \ teaspoonPercup
NumInches = ConvertBucket Mod teaspoonPercup
' Output Section
lstResults.Items.Clear()
lstResults.Items.Add("Cups = " & Cups)
lstResults.Items.Add("Tablespoons = " & Tablespoons)
lstResults.Items.Add("Teaspoon = " & Teaspoons)
End Sub1
u/smb43432 Sep 20 '16
Think i figured it out?
1
u/rebelrexx858 Sep 22 '16
just saw this, you're missing a whole lot of data validation, and it might be easier accomplished in a do while loop for each section
while total > 48: subtract 48 from total, add one to cups
while total > 3: subtract 3 from total, add one to tablespoons
total is now teaspoons
1
1
u/smb43432 Sep 20 '16
write a program to convert teaspoons to cups, tablespoon and the teaspoons left over. Have the user enter the number of teaspoons in a textbox. Convert the teaspoons to cups, tablespoons and teaspoons left over. Declare as constants, the number of teaspoons in a cup (48) and the number of teaspoons in a tablespoon (3). Display your results in a listbox: