Home > Software engineering >  Add custom controls on VB
Add custom controls on VB

Time:09-27

Directly on the code
'DisplayFormat
Public Property Get DisplayFormat () As String
DisplayFormat=gDisplayFormat
End Property
Public Property Let DisplayFormat (ByVal vNewValue As String)
GDisplayFormat=vNewValue
End Property

Private Sub UserControl_WriteProperties (PropBag As PropertyBag)
Call PropBag. WriteProperty (" DisplayFormat DisplayFormat, "")
End Sub
Private Sub UserControl_ReadProperties (PropBag As PropertyBag)
GDisplayFormat=PropBag. ReadProperty (" DisplayFormat ", "")
End Sub

If gDisplayFormat & lt;> "" Then
'If gDisplayFormat="# # 0.00" Then
'Text1. Text=Format (strTextValue, "# # 0.00")
'ElseIf gDisplayFormat="# # 0.0" Then
'Text1. Text=Format (strTextValue, "# # 0.0")
'ElseIf gDisplayFormat="# 0.0 Then"
'Text1. Text=Format (strTextValue, "# 0.0")
'End If
Text1. Text=Format (strTextValue gDisplayFormat)
End If

CodePudding user response:

Write custom control method for the first time, according to online to see, the effect may format but is not normal

CodePudding user response:

Where are you copy code?
 Option Explicit 

Private strTextValue As String
Private gDisplayFormat As String

Public Property Get DisplayFormat () As String
DisplayFormat=gDisplayFormat
End Property
Public Property Let DisplayFormat (ByVal vNewValue As String)
GDisplayFormat=vNewValue
PropertyChanged DisplayFormat "" 'to refresh the properties window'
DoFormat 'want to use it will have an effect'
End Property

Private Sub UserControl_Initialize ()
StrTextValue="https://bbs.csdn.net/topics/1.2" 'I added the test data of'
End Sub

Private Sub UserControl_WriteProperties (PropBag As PropertyBag)
Call PropBag. WriteProperty (" DisplayFormat DisplayFormat, "")
End Sub
Private Sub UserControl_ReadProperties (PropBag As PropertyBag)
Me. DisplayFormat=PropBag. ReadProperty (" DisplayFormat ", "") 'to attribute assignment will automatically call DoFormat, will have an effect'
End Sub

Private Sub DoFormat ()
If gDisplayFormat & lt;> "" Then
Text1. Text=Format (strTextValue gDisplayFormat)
End the If
End Sub
  • Related