I'm learning Visual Basic using the .Net Framework 2.0. I have been playing
with consuming web services in applications.
I am using a free web service that gives me information for currency
conversion. The web service I am using is:
http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
It's got pretty much everything I need, but I'm running into trouble.
I want 2 comboboxes in the application. Both of them need to contain the
names of the currencies that provide conversion factors. The names of the
currencies are 3 letter names that are names of are ENUM constants.
The function that provides the copnversion factor takes 2 arguments -- The
currency we're converting FROM, and the currency we're converting TO.
I'm trying to get the constant names in the dropdowns.
Here's the code so far:
Imports CurrencyConvers ion.wsCurrency. CurrencyConvert or
Imports CurrencyConvers ion.wsCurrency. Currency
Imports System.Windows. Forms
Public Class frmMain
Private Sub frmMain_Load(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim wsCurrencyNames As CurrencyConvers ion.wsCurrency. Currency
Dim arrayCurrencyNa me As New ArrayList()
'For Each wsCurrencyNames In
CurrencyConvers ion.wsCurrency. Currency.GetNam es(GetType(wsCu rrency.Currency ))
'cbxFromCurrenc y.Items.Add(wsC urrencyNames.To String())
'cbxToCurrency. Items.Add(wsCur rencyNames.ToSt ring())
'Next
'cbxFromCurrenc y.DataSource =
System.Enum.Get Names(typeof(Cu rrencyConversio n.wsCurrency.Cu rrency))
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim dblRate As Double
Dim wsConvert As New wsCurrency.Curr encyConvertor
dblRate = wsConvert.Conve rsionRate(GBP, USD)
rtbResults.Text = CStr(dblRate)
End Sub
End Class
This line:
dblRate = wsConvert.Conve rsionRate(GBP, USD)
is the function that does work when values are entered directly. But I want
the user to choose from the list. Any ideas?
--
Richard Tocci
College Station, TX