Code snippets in vb.net

I have to do the distance calculation project.so 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

    Me.Close()
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
    lstDisplay.Items.Clear()

    '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"
            lstDisplay.Items.Add(strSpeedOutput)

            'Display time output
            strTimeOutput = "Time traveled: " & intTime & " hours"
            lstDisplay.Items.Add(strTimeOutput)

            'Display hour and distance labels
            strDistance = "Hour " & " " & "Distance Traveled"
            lstDisplay.Items.Add(strDistance)

            '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
                lstDisplay.Items.Add(strList)
                intCount += 1
            Loop

            'Display the total distance
            intTotalDist = intSpeed * intTime

            strTotalDist = "Total Distance: " & intTotalDist & " mile(s)"
            lstDisplay.Items.Add(strTotalDist)

        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!
Advisor

Belgium Web Net

Internet, Web Design, Digital Marketing

Advisor

Roku Activation Code

Technology, E-commerce, Domain Sales

Advisor

QR Code Tiger

Software, Technology, Internet Services

Advisor

Net Security Training

IT Security Training, Certification Courses, Information Technology