搜档网
当前位置:搜档网 › VB 控件窗口大小可调实例

VB 控件窗口大小可调实例

VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 7500
ClientLeft = 120
ClientTop = 450
ClientWidth = 7005
LinkTopic = "Form1"
ScaleHeight = 7500
ScaleWidth = 7005
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text4
Height = 270
Left = 120
TabIndex = 77
Text = "abcLog"
Top = 1680
Width = 1695
End
Begin VB.Frame Frame1
Caption = "Opened (Record in PC)"
Height = 2535
Index = 1
Left = 120
TabIndex = 38
Top = 4800
Width = 6735
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 1"
Height = 255
Index = 8
Left = 120
TabIndex = 66
Top = 720
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label5
Caption = "Pass"
Height = 255
Index = 7
Left = 960
TabIndex = 65
Top = 360
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label5
Caption = "Fail"
Height = 255
Index = 6
Left = 2040
TabIndex = 64
Top = 360
Width = 975
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label5
Caption = "Pass"
Height = 255
Index = 5
Left = 4080
TabIndex = 63
Top = 360
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label5
Caption = "Fail"
Height = 255
Index = 4
Left = 5160
TabIndex = 62
Top = 360
Width = 975
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 8
Left = 960
TabIndex = 61
Top = 720
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 9
Left = 960
TabIndex = 60
Top = 1080
Width = 855

End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 10
Left = 960
TabIndex = 59
Top = 1440
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 11
Left = 960
TabIndex = 58
Top = 1800
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 12
Left = 4320
TabIndex = 57
Top = 720
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 13
Left = 4320
TabIndex = 56
Top = 1080
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 14
Left = 4320
TabIndex = 55
Top = 1440
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 15
Left = 4320
TabIndex = 54
Top = 1800
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 8
Left = 1920
TabIndex = 53
Top = 720
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 9
Left = 1920
TabIndex = 52
Top = 1080
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H80

00000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 10
Left = 1920
TabIndex = 51
Top = 1440
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 11
Left = 1920
TabIndex = 50
Top = 1800
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 12
Left = 5280
TabIndex = 49
Top = 720
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 13
Left = 5280
TabIndex = 48
Top = 1080
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 14
Left = 5280
TabIndex = 47
Top = 1440
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 15
Left = 5280
TabIndex = 46
Top = 1800
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 2"
Height = 255
Index = 9
Left = 120
TabIndex = 45
Top = 1080
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 3"
Height = 255
Index = 10
Left = 120
TabIndex = 44
Top = 1440
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 4"
Height = 255
Index = 11
Left = 120
TabIndex = 43
Top = 1800
Width = 735
End
Begi

n https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 5"
Height = 255
Index = 12
Left = 3480
TabIndex = 42
Top = 720
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 6"
Height = 255
Index = 13
Left = 3480
TabIndex = 41
Top = 1080
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 7"
Height = 255
Index = 14
Left = 3480
TabIndex = 40
Top = 1440
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 8"
Height = 255
Index = 15
Left = 3480
TabIndex = 39
Top = 1800
Width = 735
End
End
Begin https://www.sodocs.net/doc/d812654001.html,mandButton Command2
Caption = "Open File"
Enabled = 0 'False
Height = 375
Left = 2040
TabIndex = 13
Top = 1680
Width = 975
End
Begin VB.Frame Frame1
Caption = "Closed (Record in PC)"
Height = 2535
Index = 0
Left = 120
TabIndex = 6
Top = 2160
Width = 6735
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 255
Index = 7
Left = 6240
TabIndex = 76
Top = 1800
Value = 1 'Checked
Width = 255
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 255
Index = 6
Left = 6240
TabIndex = 75
Top = 1440
Value = 1 'Checked
Width = 255
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 255
Index = 5
Left = 6240
TabIndex = 74
Top = 1080
Value = 1 'Checked
Width = 255
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 255
Index = 4
Left = 6240
TabIndex = 72
Top = 720
Value = 1 'Checked
Width = 255
End
Begin

VB.CheckBox Check1
Caption = "Check1"
Height = 255
Index = 3
Left = 2880
TabIndex = 71
Top = 1800
Value = 1 'Checked
Width = 255
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 255
Index = 2
Left = 2880
TabIndex = 70
Top = 1440
Value = 1 'Checked
Width = 255
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 255
Index = 1
Left = 2880
TabIndex = 69
Top = 1080
Value = 1 'Checked
Width = 255
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 255
Index = 0
Left = 2880
TabIndex = 67
Top = 720
Value = 1 'Checked
Width = 255
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label7
Caption = "Enabled"
Height = 255
Index = 1
Left = 6000
TabIndex = 73
Top = 360
Width = 615
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label7
Caption = "Enabled"
Height = 255
Index = 0
Left = 2760
TabIndex = 68
Top = 360
Width = 615
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 8"
Height = 255
Index = 7
Left = 3480
TabIndex = 37
Top = 1800
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 7"
Height = 255
Index = 6
Left = 3480
TabIndex = 36
Top = 1440
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 6"
Height = 255
Index = 5
Left = 3480
TabIndex = 35
Top = 1080
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 5"
Height = 255
Index = 4
Left = 3480
TabIndex = 34
Top = 720
Width = 735
End

Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 4"
Height = 255
Index = 3
Left = 120
TabIndex = 33
Top = 1800
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 3"
Height = 255
Index = 2
Left = 120
TabIndex = 32
Top = 1440
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 2"
Height = 255
Index = 1
Left = 120
TabIndex = 31
Top = 1080
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 7
Left = 5280
TabIndex = 30
Top = 1800
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 6
Left = 5280
TabIndex = 29
Top = 1440
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 5
Left = 5280
TabIndex = 28
Top = 1080
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 4
Left = 5280
TabIndex = 27
Top = 720
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 3
Left = 1920
TabIndex = 26
Top = 1800
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 2
Left = 1920
TabIndex = 25
Top = 1440

Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 1
Left = 1920
TabIndex = 24
Top = 1080
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text3
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 0
Left = 1920
TabIndex = 23
Top = 720
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 7
Left = 4320
TabIndex = 22
Top = 1800
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 6
Left = 4320
TabIndex = 21
Top = 1440
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 5
Left = 4320
TabIndex = 20
Top = 1080
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 4
Left = 4320
TabIndex = 19
Top = 720
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 3
Left = 960
TabIndex = 18
Top = 1800
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 2
Left = 960
TabIndex = 17
Top = 1440
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2

BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 1
Left = 960
TabIndex = 16
Top = 1080
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Text2
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 255
Index = 0
Left = 960
TabIndex = 14
Top = 720
Width = 855
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label5
Caption = "Fail"
Height = 255
Index = 3
Left = 5160
TabIndex = 11
Top = 360
Width = 975
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label5
Caption = "Pass"
Height = 255
Index = 2
Left = 4080
TabIndex = 10
Top = 360
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label5
Caption = "Fail"
Height = 255
Index = 1
Left = 2040
TabIndex = 9
Top = 360
Width = 975
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label5
Caption = "Pass"
Height = 255
Index = 0
Left = 960
TabIndex = 8
Top = 360
Width = 735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label4
Caption = "Relay 1"
Height = 255
Index = 0
Left = 120
TabIndex = 7
Top = 720
Width = 735
End
End
Begin https://www.sodocs.net/doc/d812654001.html,boBox Combo1
Height = 300
ItemData = "Form1.frx":0000
Left = 120
List = "Form1.frx":0031
Style = 2 'Dropdown List
TabIndex = 2
Top = 360
Width = 1215
End
Begin VB.Timer ctrTimer
Left = 6480
Top = 2160
End
Begin MSCommLib.MSComm MSComm1
Left = 6600
Top = 240
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin https://www.sodocs.net/doc/d812654001.html,mandButton Command1
Caption = "Start"
Height = 375
Left = 2040
TabIndex = 1
Top = 360
Width = 975

End
Begin VB.TextBox Text1
Height = 1575
Left = 3120
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Top = 360
Width = 3735
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label8
Caption = "Log file name"
Height = 255
Left = 120
TabIndex = 78
Top = 1440
Width = 1215
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Test_times
BackColor = &H8000000E&
BorderStyle = 1 'Fixed Single
Caption = "0"
Height = 375
Left = 120
TabIndex = 15
Top = 960
Width = 1695
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label6
Caption = "Test Comment"
Height = 255
Left = 3120
TabIndex = 12
Top = 120
Width = 1455
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label3
Caption = "Test times"
Height = 255
Left = 120
TabIndex = 5
Top = 720
Width = 1815
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label2
Caption = "COM:"
Height = 255
Left = 120
TabIndex = 4
Top = 105
Width = 1815
End
Begin https://www.sodocs.net/doc/d812654001.html,bel Label1
Caption = "Closed"
ForeColor = &H000000FF&
Height = 375
Left = 1440
TabIndex = 3
Top = 420
Width = 615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit '自动调节窗口大小

Private FormOldWidth As Long '自动调节窗口大小

'保存窗体的原始宽度

Private FormOldHeight As Long '自动设节窗口大小
'保存窗体的原始高度


Private Declare Sub sleep Lib "kernel32" Alias "Sleep" (ByVal dwmiliseconds As Long)
Dim saveBuffer(9) As Byte
Dim savebuffercount As Integer
Dim Data_Sum As Long
Dim test_col As Integer



Const Relay_Close_1_4 = 0
Const Relay_Close_5_8 = 4
Const Relay_Open_1_4 = 8
Const Relay_Open_5_8 = 12



Private Function HexToDec(ByVal strHex As String) As Long
On Error GoTo ErrorDo
Dim Tmp As Long
Dim s As String
s = "&H " & strHex
Tmp = Val(s)
HexToDec = Tmp
Exit Function
ErrorDo:
HexToDec = -1
End Function

Private Sub Check1_Click(Index As Integer)
Label4(Index).Enabled = Check1(Index)
Label4(Index + 8).Enabled = Check1(Index)
Text2(Index).Enabled = Check1(Index)
Text2(Index + 8).En

abled = Check1(Index)
Text3(Index).Enabled = Check1(Index)
Text3(Index + 8).Enabled = Check1(Index)

End Sub

Private Sub Command1_Click()
Dim i As Integer
On Error GoTo ERR
If Command1.Caption = "Start" Then
https://www.sodocs.net/doc/d812654001.html,mPort = Combo1.ListIndex + 1 '设置串行端口com1
MSComm1.PortOpen = True
Command1.Caption = "Stop"
Label1.Caption = "Opened"
Label1.ForeColor = &HC000&
Combo1.Enabled = False
Command2.Enabled = False
'添加客户提醒,是否覆盖原文件


Text4.Enabled = False
For i = 0 To 7
Check1(i).Enabled = False
Next
Text1 = Text1 + "Start test at " + Str(Now()) + Chr(13) + Chr(10)
Else
MSComm1.PortOpen = False
Command1.Caption = "Start"
Label1.Caption = "Closed"
Label1.ForeColor = &HFF&
Combo1.Enabled = True
Command2.Enabled = True
Text4.Enabled = True
For i = 0 To 7
Check1(i).Enabled = True
Next
Text1 = Text1 + "Stop test at " + Str(Now()) + Chr(13) + Chr(10)
End If
Exit Sub
ERR:
Label1.Caption = "Error"
Label1.ForeColor = &HFF&
End Sub

Private Sub Command2_Click()
Open file(App.Path + "a.txt") For Output As #1
'Write #1,





End Sub

Private Sub Form_Load()

Call ResizeInit(Form1) '在程序装入时必须加入 '自动设节窗口大小

MSComm1.Settings = "9600,N,8,1" '设置波特率及数据帧格式
MSComm1.InputLen = 0 '读取接收缓冲区的所有字符
MSComm1.InBufferSize = 1024 '数据接受缓冲区大小为4000字节
MSComm1.OutBufferSize = 256 '数据发送缓冲区大小为4000字节

MSComm1.RThreshold = 1 '每1位数据到接收缓冲区都触发接收事件

'MSComm1.SThreshold = 1 '发送缓冲区空触发发送事件
'MSComm1.InputMode = comInputModeText '字节模式


'设定 InputMode 以读取二进位资料
MSComm1.InputMode = comInputModeBinary





End Sub


Private Sub MSComm1_OnComm()

Static cnt As Integer
Dim receive_cnt As Integer
Dim i As Integer
Dim Lakh As Long
Dim Ts As Long
Dim Ten As Long
Dim Nu As Long

Dim Buffer() As Byte




Select Case https://www.sodocs.net/doc/d812654001.html,mEvent

Case comEvReceive
'sleep (20)
'receive_cnt = MSComm1.InBufferCount '接收缓冲区的字节数

' 往暂存区存二进位资料
Buffer = MSComm1.Input
For i = 0 To UBound(Buffer) - LBound(Buffer)
'Debug.Print i & "_" & Buffer(i)
If Buffer(i) = 161 Then
savebuffercount = 0
'saveBuffer(0) = Buffer(i)
Else
savebuffercount = savebuffercount + 1
If savebuffercount < 9 Then
saveBuffer(savebuffercount) = Buffer(i)
If savebuffercount = 8 Then
Lakh = saveBuffer(1)
Ts = saveBuffer(2

)
Ten = saveBuffer(3)
Nu = saveBuffer(4)
Data_Sum = Lakh * 100000 + Ts * 1000 + Ten * 10 + Nu

Call relay_Status(5, Relay_Close_1_4)
Call relay_Status(6, Relay_Close_5_8)
Call relay_Status(7, Relay_Open_1_4)
Call relay_Status(8, Relay_Open_5_8)
'Text1 = Text1 & Str(Data_Sum) & Str(saveBuffer(5)) & Str(saveBuffer(6)) & Str(saveBuffer(7)) & Str(saveBuffer(8))
Test_times = Data_Sum
End If
End If
End If

Next
' 指定给位元组阵列以便处理




'Text1.Text = HexToDec(Text1.Text)


'If cnt >= 300 Then
' Text1.Text = ""
' cnt = 0
' Exit Sub
'End If

Case comEvSend

End Select
End Sub

Private Sub ctrTimer_Timer()
Dim longth As Integer

strSendText = frmMain.txtSend.Text
If intOutMode = 0 Then
frmMain.txtReceive.Text = "ascii"
frmMain.ctrMSComm.Output = strSendText
Else
'add code
longth = strHexToByteArray(strSendText, bytSendByte())

If longth > 0 Then
frmMain.ctrMSComm.Output = bytSendByte
End If

End If

End Sub

Sub relay_Status(Bufferi As Integer, textNum As Integer)

'*****************************************************
'转换数据成继电器状态
Dim PN As Integer, OpeClo As String
Dim i As Integer
If Bufferi Mod 2 Then '继电器序号
PN = 1
Else
PN = 5
End If
If textNum <= Relay_Close_5_8 Then '继电器测试的闭合与断开
OpeClo = " close"
Else
OpeClo = " open"
End If

For i = 0 To 3
If Check1(PN + i - 1) Then
If saveBuffer(Bufferi) And 2 ^ (3 - i) Then
Text2(textNum + i) = Val(Text2(textNum + i)) + 1
Else
Text3(textNum + i) = Val(Text3(textNum + i)) + 1


If test_col > 5 Then 'Text1最多显示5行
Text1 = ""
test_col = 0
End If
Text1 = Text1 + "Relay" + Str(PN + i) + OpeClo + " failed at times" + Str(Data_Sum) + " " + Str(Now()) + Chr(13) + Chr(10)
test_col = test_col + 1
End If
End If
Next
'*****************************************************
End Sub



Private Sub Text3_Click(Index As Integer)
0
End Sub

'在调用ResizeForm前先调用本函数 '自动设节窗口大小

Public Sub ResizeInit(FormName As Form)

Dim Obj As Control

FormOldWidth = FormName.ScaleWidth

FormOldHeight = FormName.ScaleHeight

On Error Resume Next

For Each Obj In FormName

Obj.Tag = Obj.Left & " " & Obj.Top & " " _
& Obj.Width & " " & Obj.Height & " "

Next Obj

On Error GoTo 0

End Sub



'按比例改变表单内各元件的大小,在调用ReSizeForm前先调用ReSizeInit函数 '自动设节窗口大小

Public Sub ResizeForm(FormName As Form)

Dim Pos(4) As Double

Dim i As Long, TempPos As Long, StartPos As Long

Dim Obj As Control

Dim ScaleX As Double, ScaleY As Double


ScaleX = FormName.ScaleWidth / FormOldWidth

'保存窗体宽度缩放比例

ScaleY = FormName.ScaleHeight / FormOldHeight

'保存窗体高度缩放比例

On Error Resume Next

For Each Obj In FormName

StartPos = 1

For i = 0 To 4

'读取控件的原始位置与大小


TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)

If TempPos > 0 Then

Pos(i) = Mid(Obj.Tag, StartPos, TempPos - StartPos)

StartPos = TempPos + 1

Else

Pos(i) = 0

End If

'根据控件的原始位置及窗体改变大小的比例对控件重新定位与改变大小

Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, _
Pos(2) * ScaleX, Pos(3) * ScaleY

Next i

Next Obj

On Error GoTo 0

End Sub


Private Sub Form_Resize() '自动设节窗口大小

Call ResizeForm(Form1) '确保窗体改变时控件随之改变

End Sub




相关主题