从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