📄 dlgchangecase.frm
字号:
VERSION 5.00
Begin VB.Form DlgChangeCase
BorderStyle = 3 'Fixed Dialog
Caption = "Change Case"
ClientHeight = 2520
ClientLeft = 45
ClientTop = 330
ClientWidth = 3495
Icon = "DlgChangeCase.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2520
ScaleWidth = 3495
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.OptionButton OptCase
Caption = "tO&GGLE cASE"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 4
Left = 240
TabIndex = 4
Top = 1560
Width = 1575
End
Begin VB.OptionButton OptCase
Caption = "&Title Case"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 3
Left = 240
TabIndex = 3
Top = 1200
Width = 1575
End
Begin VB.OptionButton OptCase
Caption = "&UPPERCASE"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 240
TabIndex = 2
Top = 840
Value = -1 'True
Width = 1575
End
Begin VB.OptionButton OptCase
Caption = "&lowercase."
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 240
TabIndex = 1
Top = 480
Width = 1575
End
Begin VB.CommandButton cmdOK
Caption = "OK"
Default = -1 'True
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 345
Left = 1200
TabIndex = 5
Top = 2040
Width = 1020
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "Cancel"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 345
Left = 2340
TabIndex = 6
Top = 2040
Width = 1020
End
Begin VB.OptionButton OptCase
Caption = "&Sentence case."
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 240
TabIndex = 0
Top = 120
Width = 1575
End
End
Attribute VB_Name = "DlgChangeCase"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CurrOpt As Byte
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Unload Me
Select Case CurrOpt
Case 0
MDIfrm.ActiveForm.ActiveControl.SelRTF = ChangeInSentenceCase(MDIfrm.ActiveForm.ActiveControl.SelText)
Case 1
MDIfrm.ActiveForm.ActiveControl.SelRTF = LCase(MDIfrm.ActiveForm.ActiveControl.SelRTF)
Case 2
MDIfrm.ActiveForm.ActiveControl.SelRTF = UCase(MDIfrm.ActiveForm.ActiveControl.SelRTF)
Case 3
MDIfrm.ActiveForm.ActiveControl.SelRTF = ChangeInTitleCase(MDIfrm.ActiveForm.ActiveControl.SelText)
Case 4
MDIfrm.ActiveForm.ActiveControl.SelRTF = ChangeIntOGGLEcASE(MDIfrm.ActiveForm.ActiveControl.SelText)
End Select
End Sub
Private Sub Form_Load()
CurrOpt = 2
End Sub
Private Sub OptCase_Click(Index As Integer)
CurrOpt = Index
End Sub
Private Function ChangeInSentenceCase(str_ As Variant)
Dim SentenceStart As Boolean
Dim NewStr_ As Variant
NewStr_ = ""
SentenceStart = True
For i = 1 To Len(str_)
If Mid(str_, i, 1) = "." Then
SentenceStart = True
NewStr_ = NewStr_ & LCase(Mid(str_, i, 1))
Else
If SentenceStart = True Then
If Mid(str_, i, 1) = " " Then
Else
SentenceStart = False
End If
NewStr_ = NewStr_ & UCase(Mid(str_, i, 1))
Else
NewStr_ = NewStr_ & LCase(Mid(str_, i, 1))
End If
End If
Next i
ChangeInSentenceCase = NewStr_
End Function
Private Function ChangeInTitleCase(str_ As Variant)
Dim WordStart As Boolean
Dim NewStr_ As Variant
NewStr_ = ""
WordStart = True
For i = 1 To Len(str_)
If Mid(str_, i, 1) = " " Then
WordStart = True
NewStr_ = NewStr_ & Mid(str_, i, 1)
Else
If WordStart = True Then
If Mid(str_, i, 1) = " " Then
Else
WordStart = False
End If
NewStr_ = NewStr_ & UCase(Mid(str_, i, 1))
Else
NewStr_ = NewStr_ & LCase(Mid(str_, i, 1))
End If
End If
Next i
ChangeInTitleCase = NewStr_
End Function
Private Function ChangeIntOGGLEcASE(str_ As Variant)
Dim WordStart As Boolean
Dim NewStr_ As Variant
NewStr_ = ""
WordStart = True
For i = 1 To Len(str_)
If Mid(str_, i, 1) = " " Then
WordStart = True
NewStr_ = NewStr_ & Mid(str_, i, 1)
Else
If WordStart = True Then
If Mid(str_, i, 1) = " " Then
Else
WordStart = False
End If
NewStr_ = NewStr_ & LCase(Mid(str_, i, 1))
Else
NewStr_ = NewStr_ & UCase(Mid(str_, i, 1))
End If
End If
Next i
ChangeIntOGGLEcASE = NewStr_
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -