Public Sub changePoints(ByVal Name As String, StartPoint As Boolean, Point As Integer)
Locations(Point).Name = Name
If StartPoint = True Then
For i = 0 To 19
Locations(i).StartPoint = False
Next
End If
Locations(Point).StartPoint = StartPoint
DrawGraph()
End Sub
Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
GraphicalPlot.changePoints(PointNameBox.Text, MakeStart.Checked, LoadedPointValue)
End Sub
所以我有2種形式。第一種形式,當點擊一個選定的點時,在可編輯的文本框中顯示第二個形式的點的詳細信息。當您單擊第二個窗體上的保存按鈕以保存細節時,上面的第二個子例程會運行,並在保存全局變量的第一個窗體中調用子例程。全局數組不保存它所做的更改
的信息傳遞到在正確的第一形式的子程序。當我改變它後立即檢查全局數組的值(緊跟在Locations(Point).Name = Name之後),它表示該值已被正確更改。
然而,子程序結束後,在全局陣列返回到它有子程序被調用之前,並沒有i的輸入的信息發送到第二形式跡的值。
如果有幫助,全球陣列是一個結構:
Structure EnteredPoint
Dim Xcoord As Integer 'Stores X co-ordinate of point
Dim Ycoord As Integer 'Store Y co-ordinate of point
Dim Name As String 'Stores name of point, used to check if point is unused
Dim StartPoint As Boolean 'Checks if the point is the start point
Dim Selected As Boolean 'Checks if the point is currently being hovered over the mouse
Dim nextPoint As Integer 'Used to implement a linked list, making deleting and recreating points easier
End Structure
名稱變回那是什麼應該是不可能的;我的程序在初始化之外改變名稱的唯一時間(將其設置爲「未使用」,或已創建的點數)在這裏。
我GOOGLE了它,把它拿給我的老師和朋友,我們不能任憑它玩了幾個小時找到任何東西。任何幫助將不勝感激,因爲這是我的Comp4課程!
編輯:增加了對vbnet3d
Sub DrawGraph()
'Used to draw the current state.
G = Me.CreateGraphics
G.Clear(Color.White) 'Sets entire background to white
Dim placeholder As Integer = 0 'Used to store the current point being checked.
If UsedLocations > 0 Then 'This part will only run if any points have been made
Do Until Locations(placeholder).nextPoint = 0 'Loops until all points have been drawn
If Locations(placeholder).StartPoint = True Then 'will only draw this if it is the starting point
G.FillEllipse(Brushes.LightBlue, Locations(placeholder).Xcoord - 3, Locations(placeholder).Ycoord - 3, 16, 16)
End If
If Locations(placeholder).Selected = True Then 'Will only draw this if it is the currently selected point
G.FillEllipse(Brushes.LightGreen, Locations(placeholder).Xcoord - 3, Locations(placeholder).Ycoord - 3, 16, 16)
End If
'Draws the actual Point
G.FillEllipse(Brushes.Black, Locations(placeholder).Xcoord, Locations(placeholder).Ycoord, 10, 10)
If UsedLocations <= 20 Then
placeholder = Locations(placeholder).nextPoint 'Gets the next point to be checked.
End If
Loop
If UsedLocations = 20 Then
If Locations(placeholder).Selected = True Then 'Will only draw this if it is the currently selected point
G.FillEllipse(Brushes.LightGreen, Locations(placeholder).Xcoord - 3, Locations(placeholder).Ycoord - 3, 16, 16)
End If
'Draws the actual Point
G.FillEllipse(Brushes.Black, Locations(placeholder).Xcoord, Locations(placeholder).Ycoord, 10, 10)
End If
End If
End Sub
哪裏位置的數組聲明? – vbnet3d
可能與默認表單引用有關。什麼是表單名稱? – Plutonix
位置數組聲明在公共類的頂部,全局,第一行圖形區域 – Hellfire