Crearea unui program in Visual Basic 2005
Express Edition
care acceseaza serviciul WEB de la www.infovalutar.ro
Crista Cristian e-mail:ccioan@yahoo.com
Pasul
1. Se deschide aplicatia Visual Basic 2005 Express
Edition si se creeaza un nou proiect
Pasul
2. Se adauga o referinta WEB la InfoValutar:
Pasul
3. Apare urmatorul ecran, in care tastati adresa http://www.infovalutar.ro/curs.asmx?WSDL
dupa care apasati butonul Go
Pasul
4. In ecranul care apare apasati butonul Add Reference
Pasul
5. Adaugati o fereastra Form1 cu numele VB Curs valutar
Pasul
6. Creati urmatoarele controale:
- 2 controale GroupBox
- 7 controale Label
- 8 controale TextBox
- 1 control ComboBox
- 2 butoane Button
Pentru
controlrul ComboBox este necesar sa creat o lista cu 3 elemente EUR, USD si RON
Pasul
7. Introduceti urmatorul cod la declaratii
Dim
curs_valuta(0 To 2) As
Double
Dim valoare_curs As
VB_cursvalutar.ro.infovalutar.www.Curs
Pasul
8. Introduceti urmatorul cod la incarcarea aplicatiei
Private
Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
valoare_curs = New VB_cursvalutar.ro.infovalutar.www.Curs()
curs_valuta(0)
= valoare_curs.GetLatestValue(ro.infovalutar.www.IDMoneda.EUR)
curs_valuta(1) =
valoare_curs.GetLatestValue(ro.infovalutar.www.IDMoneda.USD)
TextBox7.Text =
curs_valuta(0)
End Sub
Pasul
9.Introduceti urmatorul cod la butonul Reseteaza
Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button1.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox1.Focus()
End Sub
Pasul
10.Introduceti urmatorul cod la butonul Iesire
Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
End
End Sub
Pasul
11.Introduceti urmatorul cod la casuta de text corespunzatoare etichetei Valoare
fara TVA
Private Sub
TextBox1_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
TextBox1.TextChanged
On Error
Resume Next
TextBox4.Text = ""
TextBox2.Text =
Str(Val(TextBox1.Text) * 0.19)
TextBox3.Text = Str(Val(TextBox1.Text) * 1.19)
Select Case ComboBox1.Text
Case "EUR"
TextBox8.Text = Str(Val(TextBox3.Text) *
curs_valuta(0))
Case "USD"
TextBox8.Text = Str(Val(TextBox3.Text) *
curs_valuta(1))
Case Else
TextBox8.Text = Str(Val(TextBox3.Text))
End Select
End Sub
Pasul
12.Introduceti urmatorul cod la casuta de text corespunzatoare etichetei Valoare
cu TVA
Private Sub TextBox4_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox4.TextChanged
On Error
Resume Next
TextBox1.Text = ""
TextBox5.Text = Val(TextBox4.Text - Val(TextBox4.Text) /
1.19)
TextBox6.Text = Str(Val(TextBox4.Text) / 1.19)
Select Case ComboBox1.Text
Case "EUR"
TextBox8.Text = Str(Val(TextBox6.Text) * curs_valuta(0))
Case "USD"
TextBox8.Text = Str(Val(TextBox6.Text) *
curs_valuta(1))
Case Else
TextBox8.Text = Str(Val(TextBox6.Text))
End Select
End Sub
Puteti descarca aplicatia aici Download