|
Public Class GetQuote
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Button2 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(136, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(64, 20)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(136, 64)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 24)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Quote"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(136, 40)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(136, 16)
Me.Label1.TabIndex = 2
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 16)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(120, 16)
Me.Label2.TabIndex = 3
Me.Label2.Text = "Enter a ticker symbol:"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 40)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(104, 16)
Me.Label3.TabIndex = 4
Me.Label3.Text = "Delayed quote:"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(208, 64)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 24)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Exit"
'
'GetQuote
'
Me.AutoScale = False
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(280, 93)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.Label2, Me.Label1, Me.Button1, Me.TextBox1, Me.Button2})
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "GetQuote"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Get Quote from Yahoo"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myQuoteProvider As New QuoteProvider()
myQuoteProvider.Symbol = TextBox1.Text
Label1.Text = "Getting quote..."
Me.Refresh()
Try
Label1.Text = [String].Format("{0} = {1}", myQuoteProvider.Symbol.ToUpper, myQuoteProvider.Quote)
Catch ex As Exception
Label1.Text = "Error"
MsgBox(GetErrorString(ex), MsgBoxStyle.Critical, "Error getting quote")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Function GetErrorString(ByVal ex As Exception) As String
Dim mySB As New System.Text.StringBuilder()
AddErrorString(mySB, ex)
Return mySB.ToString
End Function
Private Sub AddErrorString(ByRef mySB As System.Text.StringBuilder, ByRef ex As Exception)
mySB.Append(ex.Message + vbCrLf)
If Not ex.InnerException Is Nothing Then
AddErrorString(mySB, ex.InnerException)
End If
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.