代码中就不会显示这个控件的一些属性值,比如“标题”,
有没有办法能够重新生成一次代码,使里面添加了界面的属性信息?
17 个解决方案
#1
有些属性取默认值时不在.frm中出现。
用记事本或其它文本编辑器直接编辑修改.frm文件前面的一大段Begin...End窗口元素即可。
用记事本或其它文本编辑器直接编辑修改.frm文件前面的一大段Begin...End窗口元素即可。
#2
LZ:你要的信息在保存的窗体*.frm中,可以用记事本来打开*.frm查看.它包含使用控件的界面数据及各控件你所写的代码.
见我的一个frmComm.frm用记事打开看到的内容(红色是控件界面数据):
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form frmComm
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin MSCommLib.MSComm MSComm1
Left = 2835
Top = 1335
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.CommandButton cmdStar
Caption = "打开串口"
Height = 495
Left = 435
TabIndex = 1
Top = 1290
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 1770
TabIndex = 0
Top = 765
Width = 1215
End
Begin MSCommLib.MSComm MSComm
Left = 2040
Top = 1320
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
End
Attribute VB_Name = "frmComm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = FalseOption Explicit
Dim key As Boolean
Dim byteSend(1) As Byte
Dim n As Long
Dim Target As Boolean
Dim CommPort As Long
Dim commbaud As String
Private Sub Command1_Click()
Print Timer
key = False
'Call men
Call wai
'Call camer
Call wai
Print Timer
For n = 1 To 3
'Call camera_number(n)
Call wai
Print Timer
Next
Print Timer
End Sub
Private Sub Form_Load()
With MSComm1
.CommPort = 1
.InputMode = comInputModeBinary
.InputLen = 2
.RThreshold = 0
.SThreshold = 0
.Settings = "9600,N,8,1"
'.PortOpen = True
.RTSEnable = False
.DTREnable = False
.EOFEnable = False
End With
byteSend(0) = &H12
byteSend(1) = &HFF
End Sub
Private Sub MSComm_OnComm()
'/**************oncomm事件处理项***********************/
Dim buf() As Byte
Dim in_str As Variant
Select Case MSComm.CommEvent
Case comEvReceive
in_str = MSComm.Input
buf = in_str '把variant中的数据赋值给文件数组
Open "D:\Comm.txt" For Binary As #1
If LOF(1) >= 5242880 Then
Close #1
MsgBox "完成存储"
End If
Seek #1, LOF(1) + 1
Put #1, , buf
Close #1
End Select
End Sub
'OnComm 事件:
Private Sub MSComm1_OnComm()
Dim inbuff As Variant
Dim inputby As Variant
Select Case MSComm1.CommEvent
Case comEvReceive
inbuff = MSComm1.Input
inputby = AscB(inbuff)
If inputby = &H80 Then '当接收到单片机的 &H80信号时才发送数据 ,单片机发送信号为 A0 80……AF 80,每隔一秒 还发送时间信号
MSComm1.RThreshold = 0
MSComm1.Output = byteSend
'Call DelayTime(m) '延时
key = True
End If
Case Else
End Select
End Sub
Private Function wai()
MSComm1.InBufferCount = 0
MSComm1.RThreshold = 1
Do
DoEvents
Loop Until key = True '(key为标志量)
key = False
End Function
Private Sub cmdStar_Click()
If Target Then
cmdStar.Caption = "打开串口"
If MSComm.PortOpen = True Then
MSComm.PortOpen = False
End If
Else
cmdStar.Caption = "关闭串口"
CommPort = 1 'Xxx '获取串口端口号
commbaud = "9600,n,8,1" 'Xxx '获取波特率
MSComm.CommPort = CommPort
MSComm.Settings = commbaud
MSComm.InputMode = comInputModeBinary
MSComm.InBufferSize = 128 '接收缓冲区大小
MSComm.OutBufferSize = 16 '发送缓冲区大小
MSComm.InputLen = 8 '缓冲区发送字节数
MSComm.RThreshold = 2 '产生omcomm事件的最小字节数
If MSComm.PortOpen = False Then
MSComm.PortOpen = True
End If
End If
Target = Not Target
End Sub
#3
可以把form的caption显示出来,但form里其他控件的caption值还是没有~~~
#4
比如~~
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} frmInstructionsP1
Caption = "MoreSteam.com Multiple Regression Template - Data Entry"
ClientHeight = 8820
ClientLeft = 45
ClientTop = 330
ClientWidth = 9105
OleObjectBlob = "frmInstructionsP1.frx":0000
ShowModal = 0 'False
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "frmInstructionsP1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cbExit_Click()
frmInstructionsP1.Hide
End Sub
Private Sub cbNext_Click()
frmInstructionsP1.Hide
frmInstructionsP2.Show
End Sub
Private Sub cmdPrint_Click()
PrintForm
End Sub
Private Sub cmdPrintAll_Click()
frmInstructionsP1.PrintForm
frmInstructionsP2.PrintForm
frmInstructionsP3.PrintForm
frmInstructionsP4.PrintForm
frmInstructionsP5.PrintForm
frmInstructionsP6.PrintForm
frmInstructionsP7.PrintForm
frmInstructionsP8.PrintForm
frmInstructionsP9.PrintForm
frmInstructionsP10.PrintForm
frmInstructionsP11.PrintForm
End Sub
#5
凡控件本身有此Caption属性的,都会在*.FRM文件中存在.
#6
啊?可是我的好奇怪,真的没显示哎~只有form的,这个是word里的VB宏,frm文件是自己导出来的。。。
#7
除非LZ的VB有问题,我将LZ帖出的代码部分做了个实验工程,将4个按钮的Caption都命名为与其在代码中Name属性一样,记事本打开,仍能看到控件的Caption数据信息.
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdPrintAll
Caption = "cmdPrintAll"
Height = 495
Left = 3240
TabIndex = 3
Top = 2055
Width = 1215
End
Begin VB.CommandButton cmdPrint
Caption = "cmdPrint"
Height = 495
Left = 3255
TabIndex = 2
Top = 1455
Width = 1215
End
Begin VB.CommandButton cbNext
Caption = "cbNext"
Height = 495
Left = 3255
TabIndex = 1
Top = 840
Width = 1215
End
Begin VB.CommandButton cbExit
Caption = "cbExit"
Height = 495
Left = 3255
TabIndex = 0
Top = 210
Width = 1215
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 Sub cbExit_Click()
frmInstructionsP1.Hide
End Sub
Private Sub cbNext_Click()
frmInstructionsP1.Hide
frmInstructionsP2.Show
End Sub
Private Sub cmdPrint_Click()
PrintForm
End Sub
Private Sub cmdPrintAll_Click()
frmInstructionsP1.PrintForm
frmInstructionsP2.PrintForm
frmInstructionsP3.PrintForm
frmInstructionsP4.PrintForm
frmInstructionsP5.PrintForm
frmInstructionsP6.PrintForm
frmInstructionsP7.PrintForm
frmInstructionsP8.PrintForm
frmInstructionsP9.PrintForm
frmInstructionsP10.PrintForm
frmInstructionsP11.PrintForm
End Sub
#8
LZ:提问到现在才说明是VBA,那我们说的是VB6.
#9
是啊,而且你是发在基础类,又不是发在VBA版,唉,我来"移动"一下吧:)
#10
呀~~ 还有VBA这东东呀~~ 俺刚知道~呵呵~
#11
看来白忙了.
#12
什么意思? 俺的问题还没得到解决呢~~~
#13
哦~ 原来刚才的代码是你贴出来的呀~~ 俺会给分的~ 谢谢哈~
#14
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP
#15
没有解决办法了么?
#16
没有解决办法了么?
#17
没有办法解决么?
#1
有些属性取默认值时不在.frm中出现。
用记事本或其它文本编辑器直接编辑修改.frm文件前面的一大段Begin...End窗口元素即可。
用记事本或其它文本编辑器直接编辑修改.frm文件前面的一大段Begin...End窗口元素即可。
#2
LZ:你要的信息在保存的窗体*.frm中,可以用记事本来打开*.frm查看.它包含使用控件的界面数据及各控件你所写的代码.
见我的一个frmComm.frm用记事打开看到的内容(红色是控件界面数据):
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form frmComm
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin MSCommLib.MSComm MSComm1
Left = 2835
Top = 1335
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.CommandButton cmdStar
Caption = "打开串口"
Height = 495
Left = 435
TabIndex = 1
Top = 1290
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 1770
TabIndex = 0
Top = 765
Width = 1215
End
Begin MSCommLib.MSComm MSComm
Left = 2040
Top = 1320
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
End
Attribute VB_Name = "frmComm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = FalseOption Explicit
Dim key As Boolean
Dim byteSend(1) As Byte
Dim n As Long
Dim Target As Boolean
Dim CommPort As Long
Dim commbaud As String
Private Sub Command1_Click()
Print Timer
key = False
'Call men
Call wai
'Call camer
Call wai
Print Timer
For n = 1 To 3
'Call camera_number(n)
Call wai
Print Timer
Next
Print Timer
End Sub
Private Sub Form_Load()
With MSComm1
.CommPort = 1
.InputMode = comInputModeBinary
.InputLen = 2
.RThreshold = 0
.SThreshold = 0
.Settings = "9600,N,8,1"
'.PortOpen = True
.RTSEnable = False
.DTREnable = False
.EOFEnable = False
End With
byteSend(0) = &H12
byteSend(1) = &HFF
End Sub
Private Sub MSComm_OnComm()
'/**************oncomm事件处理项***********************/
Dim buf() As Byte
Dim in_str As Variant
Select Case MSComm.CommEvent
Case comEvReceive
in_str = MSComm.Input
buf = in_str '把variant中的数据赋值给文件数组
Open "D:\Comm.txt" For Binary As #1
If LOF(1) >= 5242880 Then
Close #1
MsgBox "完成存储"
End If
Seek #1, LOF(1) + 1
Put #1, , buf
Close #1
End Select
End Sub
'OnComm 事件:
Private Sub MSComm1_OnComm()
Dim inbuff As Variant
Dim inputby As Variant
Select Case MSComm1.CommEvent
Case comEvReceive
inbuff = MSComm1.Input
inputby = AscB(inbuff)
If inputby = &H80 Then '当接收到单片机的 &H80信号时才发送数据 ,单片机发送信号为 A0 80……AF 80,每隔一秒 还发送时间信号
MSComm1.RThreshold = 0
MSComm1.Output = byteSend
'Call DelayTime(m) '延时
key = True
End If
Case Else
End Select
End Sub
Private Function wai()
MSComm1.InBufferCount = 0
MSComm1.RThreshold = 1
Do
DoEvents
Loop Until key = True '(key为标志量)
key = False
End Function
Private Sub cmdStar_Click()
If Target Then
cmdStar.Caption = "打开串口"
If MSComm.PortOpen = True Then
MSComm.PortOpen = False
End If
Else
cmdStar.Caption = "关闭串口"
CommPort = 1 'Xxx '获取串口端口号
commbaud = "9600,n,8,1" 'Xxx '获取波特率
MSComm.CommPort = CommPort
MSComm.Settings = commbaud
MSComm.InputMode = comInputModeBinary
MSComm.InBufferSize = 128 '接收缓冲区大小
MSComm.OutBufferSize = 16 '发送缓冲区大小
MSComm.InputLen = 8 '缓冲区发送字节数
MSComm.RThreshold = 2 '产生omcomm事件的最小字节数
If MSComm.PortOpen = False Then
MSComm.PortOpen = True
End If
End If
Target = Not Target
End Sub
#3
可以把form的caption显示出来,但form里其他控件的caption值还是没有~~~
#4
比如~~
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} frmInstructionsP1
Caption = "MoreSteam.com Multiple Regression Template - Data Entry"
ClientHeight = 8820
ClientLeft = 45
ClientTop = 330
ClientWidth = 9105
OleObjectBlob = "frmInstructionsP1.frx":0000
ShowModal = 0 'False
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "frmInstructionsP1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cbExit_Click()
frmInstructionsP1.Hide
End Sub
Private Sub cbNext_Click()
frmInstructionsP1.Hide
frmInstructionsP2.Show
End Sub
Private Sub cmdPrint_Click()
PrintForm
End Sub
Private Sub cmdPrintAll_Click()
frmInstructionsP1.PrintForm
frmInstructionsP2.PrintForm
frmInstructionsP3.PrintForm
frmInstructionsP4.PrintForm
frmInstructionsP5.PrintForm
frmInstructionsP6.PrintForm
frmInstructionsP7.PrintForm
frmInstructionsP8.PrintForm
frmInstructionsP9.PrintForm
frmInstructionsP10.PrintForm
frmInstructionsP11.PrintForm
End Sub
#5
凡控件本身有此Caption属性的,都会在*.FRM文件中存在.
#6
啊?可是我的好奇怪,真的没显示哎~只有form的,这个是word里的VB宏,frm文件是自己导出来的。。。
#7
除非LZ的VB有问题,我将LZ帖出的代码部分做了个实验工程,将4个按钮的Caption都命名为与其在代码中Name属性一样,记事本打开,仍能看到控件的Caption数据信息.
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdPrintAll
Caption = "cmdPrintAll"
Height = 495
Left = 3240
TabIndex = 3
Top = 2055
Width = 1215
End
Begin VB.CommandButton cmdPrint
Caption = "cmdPrint"
Height = 495
Left = 3255
TabIndex = 2
Top = 1455
Width = 1215
End
Begin VB.CommandButton cbNext
Caption = "cbNext"
Height = 495
Left = 3255
TabIndex = 1
Top = 840
Width = 1215
End
Begin VB.CommandButton cbExit
Caption = "cbExit"
Height = 495
Left = 3255
TabIndex = 0
Top = 210
Width = 1215
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 Sub cbExit_Click()
frmInstructionsP1.Hide
End Sub
Private Sub cbNext_Click()
frmInstructionsP1.Hide
frmInstructionsP2.Show
End Sub
Private Sub cmdPrint_Click()
PrintForm
End Sub
Private Sub cmdPrintAll_Click()
frmInstructionsP1.PrintForm
frmInstructionsP2.PrintForm
frmInstructionsP3.PrintForm
frmInstructionsP4.PrintForm
frmInstructionsP5.PrintForm
frmInstructionsP6.PrintForm
frmInstructionsP7.PrintForm
frmInstructionsP8.PrintForm
frmInstructionsP9.PrintForm
frmInstructionsP10.PrintForm
frmInstructionsP11.PrintForm
End Sub
#8
LZ:提问到现在才说明是VBA,那我们说的是VB6.
#9
是啊,而且你是发在基础类,又不是发在VBA版,唉,我来"移动"一下吧:)
#10
呀~~ 还有VBA这东东呀~~ 俺刚知道~呵呵~
#11
看来白忙了.
#12
什么意思? 俺的问题还没得到解决呢~~~
#13
哦~ 原来刚才的代码是你贴出来的呀~~ 俺会给分的~ 谢谢哈~
#14
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP
#15
没有解决办法了么?
#16
没有解决办法了么?
#17
没有办法解决么?