⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 电子书“Visual Basic 6 网络编程实例教程.rar”
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BackColor       =   &H00808000&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "创建本地URL"
   ClientHeight    =   4035
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7635
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4035
   ScaleWidth      =   7635
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command1 
      Caption         =   "创建"
      Height          =   375
      Left            =   3120
      TabIndex        =   6
      Top             =   3480
      Width           =   1455
   End
   Begin VB.TextBox Text6 
      Height          =   375
      Left            =   1440
      TabIndex        =   5
      Text            =   "Text6"
      Top             =   2880
      Width           =   5895
   End
   Begin VB.TextBox Text5 
      Height          =   375
      Left            =   1440
      TabIndex        =   4
      Text            =   "Text5"
      Top             =   2400
      Width           =   5895
   End
   Begin VB.TextBox Text4 
      Height          =   375
      Left            =   1440
      TabIndex        =   3
      Text            =   "Text4"
      Top             =   1680
      Width           =   5895
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   1440
      TabIndex        =   2
      Text            =   "Text3"
      Top             =   1200
      Width           =   5895
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   1440
      TabIndex        =   1
      Text            =   "Text2"
      Top             =   600
      Width           =   5895
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1440
      TabIndex        =   0
      Text            =   "Text1"
      Top             =   120
      Width           =   5895
   End
   Begin VB.Label Label6 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "编码的URL C"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   240
      TabIndex        =   12
      Top             =   2977
      Width           =   990
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "路径C"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   240
      TabIndex        =   11
      Top             =   2497
      Width           =   450
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "编码的URL B"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   240
      TabIndex        =   10
      Top             =   1777
      Width           =   990
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "路径B"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   240
      TabIndex        =   9
      Top             =   1297
      Width           =   450
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "编码的URL A"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   240
      TabIndex        =   8
      Top             =   697
      Width           =   990
   End
   Begin VB.Label label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "路径A"
      ForeColor       =   &H00FFFFFF&
      Height          =   180
      Left            =   240
      TabIndex        =   7
      Top             =   217
      Width           =   450
   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 sPath As String
   Dim sUrl As String
  '以Text1文本框中的内容作为参数,
  '并将结果显示在Text2文本框中
   sPath = Text1.Text
   sUrl = CreateUrlFromPath(sPath)
   Text2.Text = sUrl
  '以Text3文本框中的内容作为参数,
  '并将结果显示在Text4文本框中
   sPath = Text3.Text
   sUrl = CreateUrlFromPath(sPath)
   Text4.Text = sUrl
  '以Text5文本框中的内容作为参数,
  '并将结果显示在Text6文本框中
   sPath = Text5.Text
   sUrl = CreateUrlFromPath(sPath)
   Text6.Text = sUrl
End Sub

Private Sub Form_Load()
    '初始化各文本框的内容
   Text1.Text = "c:\my documents\vbnet articles\random access.doc"
   Text2.Text = ""
   Text3.Text = "c:\documents\vbnet\randomaccess.doc"
   Text4.Text = ""
   Text5.Text = "\\192.168.1.102\vbnet\randomaccess.htm"
   Text6.Text = ""
End Sub

Private Function CreateUrlFromPath(ByVal sPath As String) As String
   Dim sUrl As String
   Dim dwSize As Long
   If Len(sPath) > 0 Then
      sUrl = Space$(MAX_PATH)
      dwSize = Len(sUrl)
      If UrlCreateFromPath(sPath, _
                           sUrl, _
                           dwSize, _
                           0&) = ERROR_SUCCESS Then
         CreateUrlFromPath = Left$(sUrl, dwSize)
      End If  'If UrlCreateFromPath
   End If 'If Len(sUrl) > 0
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -