[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

double check my code please?

Posted on 2008-06-23
2
Medium Priority
?
159 Views
Last Modified: 2010-04-23
3rd part of my stock quote question...just want to make sure this looks clean to a trained eyeball... :^)
Imports System.IO
Imports System.Net
 
Public Class frmMain
    WithEvents tmr As New Timer
    Const strURL As String = "stocksite"
 
    Private Sub frmMain_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        Me.Size = New Size(90, 20)
        Me.BackColor = Color.FromArgb(37, 95, 220)
        Me.Location = New Point(0, Screen.PrimaryScreen.Bounds.Height - Me.Height)
        lnkQuote.BackColor = Me.BackColor
    End Sub
 
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tmr.Interval = 600000
        tmr.Enabled = True
        tmr.Start()
        UpdateQuote()
    End Sub
 
    Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
        UpdateQuote()
    End Sub
 
    Sub UpdateQuote()
        Dim client As WebClient = New WebClient
        client.Proxy = New WebProxy("myproxy", True)
        client.Proxy.Credentials = CredentialCache.DefaultCredentials
        Dim data() As Byte = client.DownloadData(strURL)
        Dim strData As String = System.Text.Encoding.ASCII.GetString(data)
 
        'Function to parse strData and get the quote information...
 
        lnkQuote.Text = strQuote
 
        If strChange.Substring(0, 1) = "+" Then lblChg.ForeColor = Color.Lime
        If strChange.Substring(0, 1) = "-" Then lblChg.ForeColor = Color.Red
        lblChg.Text = strChange
    End Sub
End Class

Open in new window

0
Comment
Question by:sirbounty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 67

Author Comment

by:sirbounty
ID: 21850481
Only thing I was thinking was to add a try/catch block when downloading the page...
0
 
LVL 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 1000 total points
ID: 21853278
Hi sirbounty!

Looks good to me. Maybe specify the parameters when setting the proxy, so it doesn't confuse True for the port number (-1). It probably won't (haven't tested it), but better to be safe than sorry....

    client.Proxy = New WebProxy(Address:="myproxy", BypassOnLocal:=True)

Wayne
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question