-
May 23rd, 2014, 02:02 AM
#1
Creating a grid in vb
Hi all,
I need to create a two dimensional grid around a point where every point of the grid must be equidistant from each other say 5 m, i.e. This point around which the grid is formed must be at the center of the grid. This grid must be spread over an area of 400 m * 400 m, i.e. in all there must be 1600 grid points. I have to do some further calculations on these grid points.
Can anyone help me in this? I am pretty new to visual basic programming. Do I need to use a two dimensional array for this? Please guide me how to go about it.
Any help would be appreciated.
Thanks
-
May 24th, 2014, 03:41 AM
#2
Re: Creating a grid in vb
I need to create a two dimensional grid around a point where every point of the grid must be equidistant from each other
as database table itself is in 2D . so you can fill your 2D table of your database in one call .see the following . hope it might help .
Code:
Private Sub Form_Load()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sqlQuery As String
sqlQuery = "Select * from Userinfo"
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\Records.mdb;Persist Security Info=False"
con.Open
rs.CursorLocation = adUseClient
rs.Open sqlQuery, con, adOpenDynamic, adLockOptimistic
If Not (rs.EOF And rs.BOF) Then
Set DataGrid1.DataSource = rs 'here in one call you can fill entire 2d row of recordset in Datagrid
End If
End Sub
-
May 24th, 2014, 09:56 AM
#3
Re: Creating a grid in vb
I'm not really sure what you are trying to do. It sounds like you are wanting to draw, maybe dots in a grid pattern?
If so then ignore the post above as a DB and data grid would not be much help.
I don't know what you mean by 5 m? I am assuming that when you say they must all be an equal distance from each other that what you really mean is the point must be an equal distance from the one above, below, left and right of it as the only way that they could all be an equal distance apart would be if they all shared the same space making the distance between 0
You may be able to just use a nested loop
Code:
Dim X as integer
Dim y as integer
For x=1 to 400
For y=1 to 400
'code to draw the point
Next
Next
Last edited by DataMiser; May 24th, 2014 at 09:58 AM.
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|