First time poster, longtime reader. I'm hoping someone can help me figure this out as I'm simply perplexed on how to do this, and I know it should be easy. I'm trying to use Visual Basic (I'm using VB2019) to generate random GPS points between a set area.
I want to find random values between:
latstart 25.761606 and latend 26.676215 -- Latitude
lonstart -80.053995 and lonend-80.053995 -- Longitude
The trouble I'm running into is when I try sample codes for generating random numbers, it rounds my coordinates to whole numbers when what I want is for the whole number and decimal to generate random.
I've tried this simple code thus far with no success:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim random As New Random
Dim lonstart As Decimal = TextBox1.Text
Dim lonend As Decimal = TextBox2.Text
Dim latstart As Decimal = TextBox3.Text
Dim latend As Decimal = TextBox4.Text
Dim templon As Decimal
Dim templat As Decimal
templon = random.Next(lonstart, lonend)
templat = random.Next(latend, latstart)
Label1.Text = templon
Label2.Text = templat
End Sub
Could someone please take a look at this and help point me in the right direction? (pun intended or not - you can decide).
I'd like to thank anyone who offers up a helpful suggestion to this problem in advance.
Thank you,
Richard
Aucun commentaire:
Enregistrer un commentaire