📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BackColor = &H80000001&
BorderStyle = 1 'Fixed Single
Caption = "创建规范的URL字符串"
ClientHeight = 4350
ClientLeft = 45
ClientTop = 330
ClientWidth = 7575
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4350
ScaleWidth = 7575
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text1
Height = 375
Left = 1320
TabIndex = 11
Text = "Text1"
Top = 240
Width = 6015
End
Begin VB.TextBox Text6
Height = 375
Left = 1320
TabIndex = 5
Text = "Text6"
Top = 3120
Width = 6015
End
Begin VB.TextBox Text5
Height = 375
Left = 1320
TabIndex = 4
Text = "Text5"
Top = 2595
Width = 6015
End
Begin VB.TextBox Text4
Height = 375
Left = 1320
TabIndex = 3
Text = "Text4"
Top = 2070
Width = 6015
End
Begin VB.TextBox Text3
Height = 375
Left = 1320
TabIndex = 2
Text = "Text3"
Top = 1290
Width = 6015
End
Begin VB.TextBox Text2
Height = 375
Left = 1320
TabIndex = 1
Text = "Text2"
Top = 765
Width = 6015
End
Begin VB.CommandButton Command1
Caption = "URL规范"
Height = 495
Left = 2880
TabIndex = 0
Top = 3720
Width = 1815
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "URLZ资源A"
ForeColor = &H00FFFFFF&
Height = 180
Left = 120
TabIndex = 12
Top = 337
Width = 810
End
Begin VB.Label Label6
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "解码URL资源B"
ForeColor = &H00FFFFFF&
Height = 180
Left = 120
TabIndex = 10
Top = 3210
Width = 1080
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "编码URL资源B"
ForeColor = &H00FFFFFF&
Height = 180
Left = 120
TabIndex = 9
Top = 2685
Width = 1080
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "URL资源B"
ForeColor = &H00FFFFFF&
Height = 180
Left = 120
TabIndex = 8
Top = 2160
Width = 720
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "解码URL资源A"
ForeColor = &H00FFFFFF&
Height = 180
Left = 120
TabIndex = 7
Top = 1393
Width = 1080
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "编码URL资源A"
ForeColor = &H00FFFFFF&
Height = 180
Left = 120
TabIndex = 6
Top = 865
Width = 1080
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 Command1_Click()
Dim sUrl As String
Dim sUrlEsc As String
'以文本框Text1中的文本作为参数,并将结果显示在Text2和Text3中
sUrl = Text1.Text
sUrlEsc = EncodeUrlCanonicalize(sUrl, URL_ESCAPE_UNSAFE)
Text2.Text = sUrlEsc
Text3.Text = EncodeUrlCanonicalize(sUrlEsc, URL_UNESCAPE)
'以文本框Text4中的文本作为参数,并将结果显示在Text5和Text6中
sUrl = Text4.Text
sUrlEsc = EncodeUrlCanonicalize(sUrl, URL_ESCAPE_UNSAFE)
Text5.Text = sUrlEsc
Text6.Text = EncodeUrlCanonicalize(sUrlEsc, URL_UNESCAPE)
End Sub
Private Function EncodeUrlCanonicalize(ByVal sUrl As String, _
dwFlags As Long) As String
Dim sUrlEsc As String
Dim dwSize As Long
If Len(sUrl) > 0 Then
sUrlEsc = Space$(MAX_PATH)
dwSize = Len(sUrlEsc)
If UrlCanonicalize(sUrl, _
sUrlEsc, _
dwSize, _
dwFlags) = ERROR_SUCCESS Then
EncodeUrlCanonicalize = Left$(sUrlEsc, dwSize)
End If 'If UrlCanonicalize
End If 'If Len(sUrl) > 0
End Function
Private Sub Form_Load()
Text1.Text = "c:\my documents\vbnet articles\..\random access.doc"
Text2.Text = ""
Text3.Text = ""
Text4.Text = "http://vbnet code lib/net code/net code/ip address.htm"
Text5.Text = ""
Text6.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -