0

I'm new to Visual Basic and I am trying to set up a currency converter. I have converted a currency to UK Sterling on the first form and on the second form I want to have the same label with the same amount of UK Sterling as on the first form on the second form. Please help!

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by poojavb
0

You cannot have the same label, but you can use the same variable. The value in this variable will be shown in label on form1 and in label of form2.

'form1:
Class Form1
	Private f2 As Form2
	Public Sub New()
		InitializeComponent()
	End Sub

	Private Sub GetData()
		Dim decValue As Decimal = 123.45
		'some decimal value
		Dim strValue As String = [String].Format("{0:C}", decValue)
		'changed to currency of current language (I have Euro here, you will have Pounds if in UK)
		'show currency in label1 (on form1):
		label1.Text = strValue

		'now open (if not yet opened) and show the same currency on form2:
		If f2 Is Nothing Then
			f2 = New Form2()
		End If
		f2.UpdatingLabel(strValue)
	End Sub
End Class

'form2:
Class Form2
	Public Sub New()
		InitializeComponent()
	End Sub

	Public Sub UpdatingLabel(str As String)
		label1.Text = str
		'show currency in label1 (on form2)
	End Sub
End Class

Hopw this helps..
bye

0

I'm new to Visual Basic and I am trying to set up a currency converter. I have converted a currency to UK Sterling on the first form and on the second form I want to have the same label with the same amount of UK Sterling as on the first form on the second form. Please help!

'Form1 code goes here

Label1.Text= 'Currency amount
form2.Label1.Text=Label1.Text 'This statement can be written in form2 load event as below
'Form2 load event

Label1.Text=form1.Label1.Text

Hope this helps u

Edited by poojavb: n/a

0

Thanks that really helped, it is working now. Much appreciated

Mark the thread as solved if it helped u....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.