Code snippets in

I have to do the distance calculation I located the two images in design page.there arise the problem!! How to calculate the distance between the two images in the design page.there is no need to bother about the height ,width etc… Pls help me

Answer #1

Here try this:

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

End Sub
Private Sub btnCalculation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
    Dim intSpeed As Integer
    Dim intTime As Integer
    Dim intDistance As Integer
    Dim intTotalDist As Integer
    Dim intCount As Integer
    Dim strDistance As String
    Dim strTotalDist As String
    Dim strMessage As String
    Dim strSpeedInput As String
    Dim strSpeedOutput As String
    Dim strTimeInput As String
    Dim strTimeOutput As String
    Dim strList As String
    Dim strError As String

    'Clear the list box

    'Prompt for the speed of the vehicle
    strMessage = "Please enter the speed of the vehicle in miles-per-hour"
    strSpeedInput = InputBox(strMessage, "Speed Input")
    intSpeed = Val(strSpeedInput)

    'Check for valid speed
    If intSpeed >= 1 Then

        'Prompt for the time
        strMessage = "Please enter the time to travel in hour"
        strTimeInput = InputBox(strMessage, "Time Input")
        intTime = Val(strTimeInput)

        'Check for valid time
        If intTime >= 1 Then

            'Display speed output
            strSpeedOutput = "Vehicle speed: " & intSpeed & " MPH"

            'Display time output
            strTimeOutput = "Time traveled: " & intTime & " hours"

            'Display hour and distance labels
            strDistance = "Hour " & " " & "Distance Traveled"

            'Calculate Distance
            intCount = 1
            Do Until intCount > intTime
                intDistance = intSpeed * intCount

                'Display the value of time and distance in the list box
                strList = " " & intCount & "                 " & intDistance
                intCount += 1

            'Display the total distance
            intTotalDist = intSpeed * intTime

            strTotalDist = "Total Distance: " & intTotalDist & " mile(s)"

        Else 'Invalid time
            strError = "The time needs to be greater or equal to 1 hour"
            MessageBox.Show(strError, "Invalid Time Data", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End If

    Else 'Invalid speed
        strError = "The speed needs to be greater or equal to 1 mph"
        MessageBox.Show(strError, "Invalid Speed Data", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End If
End Sub

That is all I got for the program in VB.

Answer #2

am not sure I understood the question but can’t you just calculate it using the property location ?

More Like This
Ask an advisor one-on-one!

Belgium Web Net

Internet, Web Design, Digital Marketing


The Code Mood

Technology, Web Development, Programming


Roku Activation Code

Technology, E-commerce, Domain Sales


QR Code Tiger

Software, Technology, Internet Services