從vb6到vb.net type (Structure)要如何寫??

Home Home
引用 | 編輯 ziele
2009-02-26 21:56
樓主
推文 x0
想要把vb6寫的程式改到vb.net 可是會出錯下面的錯誤

Public Const c1 = 255
Public Const c2 = 255
Public Const c3 = 15

Public sss(0 To c1) As sta

Structure ppp
Dim X As Integer
Dim Y As Integer
Dim Alarm As String
Dim Gif As String
End Structure

Structure hhh
Dim H_Addr As String
Dim H_Name As String
Dim H_Memo As String
Dim H_Pic As String
Dim H_Mobile As String
Dim H_Mail As String
<VBFixedArray(c3)> Dim Point() As ppp

Public Sub Initialize()
R ..

訪客只能看到部份內容,免費 加入會員



獻花 x0
引用 | 編輯 Lenki
2009-03-29 02:14
1樓
  
在 VB.NET 裡的 Structure 並沒有辦法使用 Initialize() 來初始設定,
若一定要使用類似 Initialize的方式,請宣告成類別。

使用Structure則可以如下面的方式初始陣列:
Public Const c1 = 255
Public Const c2 = 255
Public Const c3 = 15

Structure ppp
  記得將 dim 改public
  public X As Integer
End Structure

Structure hhh
  public Point() As ppp
End Structure

Structure sta
  Public Home() As hhh
End Structure

  Public Sub InitRegData()
  初始化陣列大小
  dim sss(c1) as sta
  for i as integer=0 to c1
    redim sss(i).Home(c2)
    for j as integer=0 to c2
    redim sss(i).Home(j).Point(c3)
    next
  next
  初始化陣列大小完成
  下面再接你要處理、執行的程式碼……
  ……
  ……

  End Sub

獻花 x0