%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
Currency Converter
'Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.IsPostBack = False Then
' The HtmlInputSelect control accepts text or ListItem objects.
Currency.Items.Add(New ListItem("Euros", "0.85"))
Currency.Items.Add(New ListItem("Japanese Yen", "110.33"))
Currency.Items.Add(New ListItem("Canadian Dollars", "1.2"))
Graph.Visible = False
End If
End Sub
Protected Sub Convert_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Convert.ServerClick
Dim oldAmount As Decimal = Val(US.Value)
If oldAmount <= 0 Then
Result.Style("color") = "Red"
Result.InnerText = "Specify a positive number"
Else
Result.Style("color") = "Black"
' Retrieve the select ListItem object by its index number.
Dim item As ListItem = Currency.Items(Currency.SelectedIndex)
Dim newAmount As Decimal = oldAmount * Val(item.Value)
Result.InnerText = oldAmount.ToString() & " U.S. dollars = "
Result.InnerText &= newAmount.ToString() & " " & item.Text
End If
End Sub
Protected Sub ShowGraph_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ShowGraph.ServerClick
Graph.Src = "Pic" & Currency.SelectedIndex.ToString() & ".png"
'Graph.Src = "download.png"
Graph.Alt = "Currency Graph"
Graph.Visible = True
End Sub
End Class