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 CurrencyConversion.wsCurrency.CurrencyConvertor
Imports CurrencyConversion.wsCurrency.Currency
Imports System.Windows.Forms
Public Class frmMain
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim wsCurrencyNames As CurrencyConversion.wsCurrency.Currency
Dim arrayCurrencyName As New ArrayList()
'For Each wsCurrencyNames In
CurrencyConversion.wsCurrency.Currency.GetNames(GetType(wsCurrency.Currency))
'cbxFromCurrency.Items.Add(wsCurrencyNames.ToString())
'cbxToCurrency.Items.Add(wsCurrencyNames.ToString())
'Next
'cbxFromCurrency.DataSource =
System.Enum.GetNames(typeof(CurrencyConversion.wsCurrency.Currency))
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim dblRate As Double
Dim wsConvert As New wsCurrency.CurrencyConvertor
dblRate = wsConvert.ConversionRate(GBP, USD)
rtbResults.Text = CStr(dblRate)
End Sub
End Class
This line:
dblRate = wsConvert.ConversionRate(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?

Signature
Richard Tocci
College Station, TX
Tim Van Wassenhove - 19 Jun 2007 16:28 GMT
Something like this? (Perhaps it's time that i learn some vb.net)
' load data in the comboboxes...
cbxFromCurrency.DataSource =Enum.GetNames(typeof(Currency))
cbxToCurrency.DataSource = Enum.GetNames(typeof(Currency))
' handle conversion...
Currency from = CType(cbxFromCurrency.SelectedItem, Currency)
Currency to = CType(cbxToCurrency.SelectedItem, Currency)
blRate = wsConvert.ConversionRate(from, to)
Herfried K. Wagner [MVP] - 19 Jun 2007 19:51 GMT
"Tim Van Wassenhove" <timvw@newsgroup.nospam> schrieb:
> Something like this? (Perhaps it's time that i learn some vb.net)
>
> ' load data in the comboboxes...
> cbxFromCurrency.DataSource =Enum.GetNames(typeof(Currency))
> cbxToCurrency.DataSource = Enum.GetNames(typeof(Currency))
=> '... = [Enum].GetNames(GetType(Currency))'.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>