VB表单动态布局VB from的控件,让布局丰富起来

这个功能是用于一个VB的表单,用于多个单据的情况,之前会让每个单据的布局千篇一律的,现在有了这个就可以随意摆放了,让他见证奇迹吧

 

”***********************************************************

‘ ?保存控件现在位置的工具正常情况下不用的

‘*********************************************

 

Public Function saveControlsPoint(ByRef vFrom As Object, ByVal controls As String) As String

 

On Error Resume Next

Dim obectArr() As String

Dim saveStr As String

 

‘需要布置位置的控件的名称,控件数组的可以 ?名字^index

‘controls = “Label1,Command1,Text1^0”

 

objectarr = Split(controls, “,”)

For i = 0 To UBound(objectarr)

If InStr(objectarr(i), “^”) > 0 Then

Set o = CallByName(vFrom, Split(objectarr(i), “^”)(0), VbGet)(Split(objectarr(i), “^”)(1))

Else

Set o = CallByName(vFrom, objectarr(i), VbGet)

End If

saveStr = saveStr & o.name & “=” & o.Top & “,” & o.Left & “,” & o.width & “;”

Next

saveControlsPoint = saveStr

Debug.Print saveStr

End Function

 

‘saveStr = “Label1=690,765,930;Command1=660,1995,1305;Text1^0=1560,780,1410;”

‘根据配置信息,重新布置控件

Public Sub setControlsPoint(ByRef vFrom As Object, ByVal controlsSetting As String)

On Error Resume Next

Dim obectArr(), tmpStr() As String

‘Dim saveStr As String

 

objectarr = Split(controlsSetting, “;”)

For i = 0 To UBound(objectarr)

If InStr(objectarr(i), “=”) > 0 Then

tmpStr = Split(objectarr(i), “=”)

If InStr(tmpStr(0), “^”) > 0 Then

Set o = CallByName(vFrom, Split(tmpStr(0), “^”)(0), VbGet)(Split(tmpStr(0), “^”)(1))

Else

Set o = CallByName(vFrom, tmpStr(0), VbGet)

End If

o.Top = Split(tmpStr(1), “,”)(0)

o.Left = Split(tmpStr(1), “,”)(1)

o.width = Split(tmpStr(1), “,”)(2)

End If

Next

Debug.Print saveStr

End Sub

 

 

 

 

 www.maibu.ren

相关新闻

微信

联系我们团队

电话: 021-5081 6768

手机: 135 8556 4840

联系人: 黄先生

Q Q: 584902540

邮箱: info@pifasoft.cn

地址: 上海市松江区九亭镇沪松公路1100号508