...

View Full Version : Visual basic Help



eLK
09-21-2011, 03:56 AM
So here is what I'm trying to do

A sample run will look like this on the Console. (Underlined part is user input.)

Enter the total number of yards: 12853

Number of miles = 7
Number of furlongs = 2
Number of yards = 93

Press ENTER key to close console.

And here is my code

Module Module1

Sub Main()
' **************************************************************/
' Author of Program: <Justin Battenfield>
' Textbook: Starting Out With Visual Basic 2010
' Program: Assignment 04: Programming Assignment (MilesAndFurlongs)
' Due Date: September 20, 2011
' **************************************************************/
'
' ================================================================
' This program converts given number of yards
' into miles, furlongs, and yards.
' 1 mile = 1760 yards
' 1 furlong = 220 yards
' ================================================================
'
' First declare the string variables required for reading in
' the user input and displaying the results.
' Also declare the integer variables to use in calculations

Dim inMiles As Integer
Dim intYards As Integer
Dim intFurlongs As Integer
Dim inMiles As String
Dim strX As String

' Display a prompt for the user to enter the total number of yards
' Read in and store the value in the string variable
' Then convert the string value into an integr value
' so we can use it in calculations

Console.Write("Enter the total number of yards: ")
intYards = Console.ReadLine()



' Write a blank line to the Console to precede output

Console.WriteLine()

' Compute number of miles, furlongs and remaining yards
' Use integer division operator (\) to get the quotient
' Use remainder operator (Mod) to get remainder
' Refer to page 135 Table 3-4 in textbook
' Examples of integer division and modulus operator
' on page136 and 137 in textbook.


inMiles = intYards \ 1760
inMiles = intYards Mod 1760

' Then convert the integer values to string values
' so we can display it to the user on the console.




' The following two lines of code just make the Console window
' stay on the computer screen as long as you want. That is,
' till you press the ENTER key. Otherwise the Console window will
' just flash by on the screen and
' you won't be able to look at the results.

Console.WriteLine("Press ENTER key to close window.")

strX = Console.ReadLine()


End Sub

End Module

I cant get it to do any calculations? help anyone?

oracleguy
09-21-2011, 05:51 AM
What do you mean you can't get it to do any calculations? Does it not compile? I notice you have two variables that are named the same.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum