+ -
当前位置:首页 → 问答吧 → 关于VB结构体的问题

关于VB结构体的问题

时间:2011-10-21

来源:互联网

如果定义一个结构体,然后结构体本身是另一个函数的一项参数,那么另一个函数如果设置参数具体值,得怎么做呢?
如:type mot
  a as byte 
  b as byte 
  end type

  t= kkk (dw,dy,mot)那么结构体怎么赋值呢

作者: sky2008liu   发布时间: 2011-10-21

我的意思是把结构体mot的值a和b,传到函数t里

作者: sky2008liu   发布时间: 2011-10-21

谢谢了

作者: sky2008liu   发布时间: 2011-10-21

给你举个例子
VB code

Option Explicit

Private Type POINTAPI
    x As Long
    y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long


Private Sub Form_Load()
    Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
    Dim MousePoint As POINTAPI
    Call GetCursorPos(MousePoint)
    Label1.Caption = "(x=" & MousePoint.x & ",y=" & MousePoint.y & ")"
End Sub


作者: Veron_04   发布时间: 2011-10-21

简单一点就是:
Private Type MOT
a As Byte
b As Byte
End Type

Dim xMot As MOT
xMot.a = CByte(a)
xMot.b = CByte(b)
...
...
...
t = kkk(dw, dy, xMot)

作者: xxk4639   发布时间: 2011-10-21