sphenisc
9th July 2008, 08:44 AM
I have a program in VB6 containing the following Sub. I need to convert to VB2005, including the Line and PSet methods. Any ideas on how to do this? I've looked at EventHandlers, e As System.Windows.Forms.PaintEventArgs, Pictureboxes etc,etc. and have no idea what to choose, how to implement it, or generally what 90% of it means.
[I'm not a programmer, I just pretend to be one at work occasionally.]
Sub displaygrid(nx As Integer, ny As Integer, t As Integer)
FillStyle = 0: ScalingFx = 200: ScalingFy = 150
For mcol = 0 To nx
For mrow = 0 To ny
plotc = mcol * ScalingFx + 500
plotr = (ny - mrow) * ScalingFy + 500
Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), , B
If Obstacles(mcol, mrow) = True Then Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), vbBlue, BF
For i = 4 To 9
If Attractant(mcol, mrow, i) > 0 Then Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), RGB(0, 17 * Attractant(mcol, mrow, i) Mod 255, 0), BF
If DestinationsbyDesire(mcol, mrow, i) Then Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), vbMagenta, BF
Next
CellAgCounter = 1
Do While LkUpAgent(mcol, mrow, CellAgCounter) > 0
Patmc = (CellAgCounter * 2) Mod (ScalingFx - 2) + 1
Patmr = Int((CellAgCounter * 2) / (ScalingFx - 2)) * 5 + 10
Patplotc = plotc + Patmc
Patplotr = plotr + Patmr
PSet (Patplotc, Patplotr), RGB(300, 50, 6)
CellAgCounter = CellAgCounter + 1
Loop
For i = 4 To 9
If DestinationsbyDesire(mcol, mrow, i) Then Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), vbMagenta, BF
Next
Next
Next
Label1.Caption = "Cyc " & t
Label1.Refresh
End Sub
[I'm not a programmer, I just pretend to be one at work occasionally.]
Sub displaygrid(nx As Integer, ny As Integer, t As Integer)
FillStyle = 0: ScalingFx = 200: ScalingFy = 150
For mcol = 0 To nx
For mrow = 0 To ny
plotc = mcol * ScalingFx + 500
plotr = (ny - mrow) * ScalingFy + 500
Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), , B
If Obstacles(mcol, mrow) = True Then Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), vbBlue, BF
For i = 4 To 9
If Attractant(mcol, mrow, i) > 0 Then Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), RGB(0, 17 * Attractant(mcol, mrow, i) Mod 255, 0), BF
If DestinationsbyDesire(mcol, mrow, i) Then Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), vbMagenta, BF
Next
CellAgCounter = 1
Do While LkUpAgent(mcol, mrow, CellAgCounter) > 0
Patmc = (CellAgCounter * 2) Mod (ScalingFx - 2) + 1
Patmr = Int((CellAgCounter * 2) / (ScalingFx - 2)) * 5 + 10
Patplotc = plotc + Patmc
Patplotr = plotr + Patmr
PSet (Patplotc, Patplotr), RGB(300, 50, 6)
CellAgCounter = CellAgCounter + 1
Loop
For i = 4 To 9
If DestinationsbyDesire(mcol, mrow, i) Then Form1.Line (plotc, plotr)-Step(ScalingFx, ScalingFy), vbMagenta, BF
Next
Next
Next
Label1.Caption = "Cyc " & t
Label1.Refresh
End Sub