Results 1 to 14 of 14

Thread: Need a little help with vb2017...

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Need a little help with vb2017...

    Good afternoon everyone. I have what is probably a very simple problem dealing with a Timing program I am trying to write for a drag strip program that I'm trying to implement. I'm using a common online vb code that has been around for a while but would like to add a ListBox that would provide the (calculated) miles per hour for each of the times recorded. I'm a complete novice when it comes to vb and have been trying to make it work but with no success. The timing display looks like this

    Name:  Ashampoo_Snap_Tuesday, October 20, 2020_13h46m20s_002_.jpg
Views: 478
Size:  37.1 KB

    and the code that I have tried to modify is

    Public Class Form1.pdf

    If you cannot open the pdf file above, here is the code currently used.
    _____________________________________________________________________
    Code:
    Public Class Form1
        Private stopwatch As New Diagnostics.Stopwatch
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.CenterToScreen()
            Button3.Enabled = False
        End Sub
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            Dim elapsed As TimeSpan = stopwatch.Elapsed
            CircularProgressBar1.Text = String.Format("{1:00}:{2:00}",
                                                         Math.Floor(elapsed.TotalHours),
                                                         elapsed.Minutes, elapsed.Seconds)
            Label1.Text = elapsed.Milliseconds
            CircularProgressBar1.Value = elapsed.Seconds
            If elapsed.Seconds = 0 Then
                CircularProgressBar1.Value = 60
            End If
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If Button1.Text = "Start" Then
                Timer1.Start()
                stopwatch.Start()
                Button3.Enabled = False
                Button1.Text = "Stop"
            Else
                Timer1.Stop()
                stopwatch.Stop()
                Button3.Enabled = True
                Button1.Text = "Start"
            End If
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            ListBox1.Items.Add(ListBox1.Items.Count + 1 & ". " & CircularProgressBar1.Text & ":" & Label1.Text)
            ListBox2.Items.Add(500 / ListBox1.Items.Count & ". " & CircularProgressBar1.Text)
        End Sub
    
        Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
            stopwatch.Reset()
            ListBox1.Items.Clear()
            ListBox2.Items.Clear()
            CircularProgressBar1.Text = "00:00:00"
            Label1.Text = "000"
        End Sub
    End Class
    ____________________________________________________________________
    Basically, it is taking a fixed distance such as 500 (this is just a random number I will put in to make the mph come out what I want it to be) and divide it by each number recorded in ListBox1. The area I'm thinking would do this is what is listed under "Private Sub Button2"

    Can anyone give me a little help in making this work.

    Thank you in advance...

    drluv
    Last edited by Shaggy Hiker; Oct 21st, 2020 at 10:26 AM. Reason: Added CODE tags.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Need a little help with vb2017...

    VB 2017 is VB.NET, as is everything from VB.NET 2002, VB.NET 2003, VB 2005 and onwards. They officially dropped the .NET suffix from VB and VS in 2005 because .NET was supposed to be considered the default. I have asked the mods to move this thread to the proper forum. Please do not post a duplicate in the meantime.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Need a little help with vb2017...

    Also, please don't post unformatted code snippets. They are too hard to read.
    vb.net Code:
    1. Public Class Form1
    2.     Private stopwatch As New Diagnostics.Stopwatch
    3.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    4.         Me.CenterToScreen()
    5.         Button3.Enabled = False
    6.     End Sub
    7.  
    8.     Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    9.         Dim elapsed As TimeSpan = stopwatch.Elapsed
    10.         CircularProgressBar1.Text = String.Format("{1:00}:{2:00}",
    11.                                                      Math.Floor(elapsed.TotalHours),
    12.                                                      elapsed.Minutes, elapsed.Seconds)
    13.         Label1.Text = elapsed.Milliseconds
    14.         CircularProgressBar1.Value = elapsed.Seconds
    15.         If elapsed.Seconds = 0 Then
    16.             CircularProgressBar1.Value = 60
    17.         End If
    18.     End Sub
    19.  
    20.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    21.         If Button1.Text = "Start" Then
    22.             Timer1.Start()
    23.             stopwatch.Start()
    24.             Button3.Enabled = False
    25.             Button1.Text = "Stop"
    26.         Else
    27.             Timer1.Stop()
    28.             stopwatch.Stop()
    29.             Button3.Enabled = True
    30.             Button1.Text = "Start"
    31.         End If
    32.     End Sub
    33.  
    34.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    35.         ListBox1.Items.Add(ListBox1.Items.Count + 1 & ". " & CircularProgressBar1.Text & ":" & Label1.Text)
    36.         ListBox2.Items.Add(500 / ListBox1.Items.Count & ". " & CircularProgressBar1.Text)
    37.     End Sub
    38.  
    39.     Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    40.         stopwatch.Reset()
    41.         ListBox1.Items.Clear()
    42.         ListBox2.Items.Clear()
    43.         CircularProgressBar1.Text = "00:00:00"
    44.         Label1.Text = "000"
    45.     End Sub
    46. End Class

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Need a little help with vb2017...

    Welcome to VBForums

    I have moved this thread from the 'Other Basic' forum to the 'VB.Net' (VB2002 and later) forum

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little help with vb2017...

    Quote Originally Posted by si_the_geek View Post
    Welcome to VBForums

    I have moved this thread from the 'Other Basic' forum to the 'VB.Net' (VB2002 and later) forum
    Thanks...

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little help with vb2017...

    Thanks for the good advice and help...

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Need a little help with vb2017...

    String.Format("{1:00}:{2:00}",
    Math.Floor(elapsed.TotalHours),
    elapsed.Minutes, elapsed.Seconds)
    You’re ignoring argument 0.
    Math.Floor(elapsed.TotalHours), Is unused. You’re just using arguments 1 and 2

  8. #8

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little help with vb2017...

    Quote Originally Posted by .paul. View Post
    You’re ignoring argument 0.
    Math.Floor(elapsed.TotalHours), Is unused. You’re just using arguments 1 and 2
    Having never worked with vb before, I really am having a hard time understanding this. I have modified the basic layout a little to look like this what is shown below. By any chance is there anyone out there that knows vb that would be willing to fill in the missing code and maybe even making a few dollars?

    Name:  Ashampoo_Snap_Monday, October 26, 2020_20h36m28s_001_.jpg
Views: 231
Size:  43.0 KB

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Need a little help with vb2017...

    Did you ever consider reading the documentation for the String.Format method that you're using to actually learn how it works? The manual exists for a reason. RTFM is not the only way to learn and won't always provide everything you need but that doesn't mean that it should be ignored as an option.

  10. #10
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,372

    Re: Need a little help with vb2017...

    The code you are using, is only a stopwatch. so there is a gap of information from a simple stopwatch to things like "First", "Second" and especially "Miles Per Hour".

    so, if the program you are using now is telling you that it has been 12.457 seconds between you pushing button "start" and "lap", how are you going to fill the 4 new boxes "First" "Second" etc. manually? this helps you understanding what other information you must provide your program to do the task.

  11. #11

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little help with vb2017...

    Quote Originally Posted by digitalShaman View Post
    The code you are using, is only a stopwatch. so there is a gap of information from a simple stopwatch to things like "First", "Second" and especially "Miles Per Hour".

    so, if the program you are using now is telling you that it has been 12.457 seconds between you pushing button "start" and "lap", how are you going to fill the 4 new boxes "First" "Second" etc. manually? this helps you understanding what other information you must provide your program to do the task.
    I truly appreciate the input everyone. The problem is that I know how to calculate the mph for each block, simply take distance and divide by the time. The issue is the code. Not as an excuse, but at 70 years of age, I'm having a terrible time trying to understand the code required to fill in each block. I have read multiple documents and watched many video on how to do thing in vb, but it simply is not clicking with me. I would be glad to pay someone if they could simply provide that code which it would appear is not too difficult to those who use vb everyday. Please, if you can help, simply let me know.

  12. #12
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,372

    Re: Need a little help with vb2017...

    The problem is that I know how to calculate the mph for each block, simply take distance and divide by the time.
    right, and the program does not know anything about the distance, so you first need to add the distance to the program somehow: shall it be entered in a textbox or hardcoded in the program? easiest would be hardcode it as a constant. Then, this:
    Code:
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If Button1.Text = "Start" Then
                Timer1.Start()
                stopwatch.Start()
                Button3.Enabled = False
                Button1.Text = "Stop"
            Else
                Timer1.Stop()
                stopwatch.Stop()
                Button3.Enabled = True
                Button1.Text = "Start"
    ' here you can add your calculation and output code
            End If
        End Sub
    this is the code that gets executed when hiting the start/stop button. i have marked the area where you could add the additional calculation.
    I'm having a terrible time trying to understand the code required to fill in each block. I have read multiple documents and watched many video on how to do thing in vb, but it simply is not clicking with me. I would be glad to pay someone if they could simply provide that code which it would appear is not too difficult to those who use vb everyday. Please, if you can help, simply let me know.
    if you want to learn, there are people to help, if you just want to pay someone to do this, your post should be moved to the Jobs sub forum, but expect more questions as your requirement for "First", "second" is still not clear (at least to me).

  13. #13

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little help with vb2017...

    Quote Originally Posted by digitalShaman View Post
    right, and the program does not know anything about the distance, so you first need to add the distance to the program somehow: shall it be entered in a textbox or hardcoded in the program? easiest would be hardcode it as a constant. Then, this:
    Code:
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If Button1.Text = "Start" Then
                Timer1.Start()
                stopwatch.Start()
                Button3.Enabled = False
                Button1.Text = "Stop"
            Else
                Timer1.Stop()
                stopwatch.Stop()
                Button3.Enabled = True
                Button1.Text = "Start"
    ' here you can add your calculation and output code
            End If
        End Sub
    this is the code that gets executed when hiting the start/stop button. i have marked the area where you could add the additional calculation.

    if you want to learn, there are people to help, if you just want to pay someone to do this, your post should be moved to the Jobs sub forum, but expect more questions as your requirement for "First", "second" is still not clear (at least to me).
    Thank you for your quick response. Yes, the distance would be hardcoded in, and set so that the speed (mph) being displayed would come up with some reasonable display to make the children believe their car was really going fast . I would determine what number to use after running the cars on the track a number of times during the test phase and then varying it to display the speed I think is believable. There are four lanes on the track with each lane being monitored for time which would be displayed in the ListBox every time the Lap button is pushed. For each of those times, I want to simply display the mph.

    I did not realize there was a forum for Jobs, so I guess I will try that. Again, for someone who works with vb all the time, I would think this should be very simple, but there again..
    .

  14. #14

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little help with vb2017...

    Thank you to everyone for your input/comments. Someone in the forum did respond with code that solved the problem and it works great. Thank you...

    drluv

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width