simplifying codes

phaeight

New member
Joined
Jul 11, 2011
Messages
3
Programming Experience
Beginner
hello,
I need help in simplifying these code......
i know how to use function in c language.....
but i don't know how to apply it in visual basic....



[XCODE]
Public Class Form1
' Dim secondform As New Form2



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'Dim from1, to1, cabin As String
'Dim adult, child, infant As Integer
'Dim sum As String

If ComboBox1.Text = "Alor Setar" Then
from1 = ComboBox1.Text
Label7.Text = from1

If ComboBox2.Text = "Kuala Lumpur" Then
Label8.Text = ComboBox2.Text

If ComboBox6.Text = "First Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Business Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Economy Class" Then
Label9.Text = ComboBox6.Text
End If

ElseIf ComboBox2.Text = "Kuantan" Then
Label8.Text = ComboBox2.Text
If ComboBox6.Text = "First Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Business Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Economy Class" Then
Label9.Text = ComboBox6.Text
End If

End If



ElseIf ComboBox1.Text = "Kuala Lumpur" Then
from1 = ComboBox1.Text
Label7.Text = from1



If ComboBox2.Text = "Kuantan" Then
Label8.Text = ComboBox2.Text
If ComboBox6.Text = "First Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Business Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Economy Class" Then
Label9.Text = ComboBox6.Text
End If

ElseIf ComboBox2.Text = "Alor Setar" Then
Label8.Text = ComboBox2.Text
If ComboBox6.Text = "First Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Business Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Economy Class" Then
Label9.Text = ComboBox6.Text
End If
End If



ElseIf ComboBox1.Text = "Kuantan" Then
from1 = ComboBox1.Text
Label7.Text = from1



If ComboBox2.Text = "Kuala Lumpur" Then
Label8.Text = ComboBox2.Text
If ComboBox6.Text = "First Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Business Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Economy Class" Then
Label9.Text = ComboBox6.Text
End If

ElseIf ComboBox2.Text = "Alor Setar" Then
Label8.Text = ComboBox2.Text
If ComboBox6.Text = "First Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Business Class" Then
Label9.Text = ComboBox6.Text
ElseIf ComboBox6.Text = "Economy Class" Then
Label9.Text = ComboBox6.Text
End If
End If
End If



















'secondform.Show()

End Sub



Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Label1.Text = CStr(Me.DateTimePicker1.Value)

End Sub
End Class
[/XCODE]
 
A VB function declaration looks like this:
Private Function SomeMethod(ByVal arg1 As Integer, ByRef arg2 As String) As Object
    '...
End Function
That's basically all you need to know. You already know how to call functions so jusy move the appropriate code into the appropriate functions with the appropriate parameters and return types.
 
A a newbie, I struggle with this sometimes - I use a free online conversion tool where I can - it uses the open source code from the Mono project (open source .Net project) spun off by Hewlet Packard (I think could be wrong). [Not sure how relevant it is to you but its a good learning tool]

http://www.developerfusion.com/tools/convert/csharp-to-vb/

I
ts quite good for small snippets of code, but it does break spectacularly sometimes and I then have to post in here!!
 
Back
Top