📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(448, 104)
Me.Label1.TabIndex = 0
Me.Label1.Text = "本程序示例了使用Windows Forms调用Web Service。按下<调用>按钮后,就调用http://localhost/SimpleWebService" & _
"/Service1.asmx,取得结果,显示在label中。" & Microsoft.VisualBasic.ChrW(13) & Microsoft.VisualBasic.ChrW(10) & "实作该实例,你能将能:" & Microsoft.VisualBasic.ChrW(13) & Microsoft.VisualBasic.ChrW(10) & "一、学会使用VS.NET集成开发环境调用Web Service的步骤。" & _
"" & Microsoft.VisualBasic.ChrW(13) & Microsoft.VisualBasic.ChrW(10) & "二、初步体验Web Service。" & Microsoft.VisualBasic.ChrW(13) & Microsoft.VisualBasic.ChrW(10) & "三、体验控制控件外观的技巧。"
'
'Label2
'
Me.Label2.BackColor = System.Drawing.SystemColors.ControlDarkDark
Me.Label2.Font = New System.Drawing.Font("宋体", 36.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label2.ForeColor = System.Drawing.Color.Cyan
Me.Label2.Location = New System.Drawing.Point(32, 152)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(408, 64)
Me.Label2.TabIndex = 1
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(184, 240)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(104, 32)
Me.Button1.TabIndex = 2
Me.Button1.Text = "调 用"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(466, 303)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.Label2, Me.Label1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "使用Windows Forms调用Web Service"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'调用WebService的时间通常比较长,所以显示一个提示信息,以免运行者心急。
Label2.Text = "调用中..."
'立刻显示标签中的文字
Me.Refresh()
'定义一个localhost.Service1类的实例,该类是Web Service提供的
Dim myService As New localhost.Service1()
'调用该Web Service的HelloWebService方法,并把返回值赋给Label2.Text
Label2.Text = myService.HelloWebService
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -