Make your own free website on Tripod.com
Blog Tools
Edit your Blog
Build a Blog
RSS Feed
View Profile
« May 2012 »
S M T W T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
You are not logged in. Log in
Entries by Topic
All topics  «
4GL Class
Lab Activity
My Blog

Wednesday, February 27, 2008

Codes - Car RentaL (with Class)
Mood:  cool
Topic: Lab Activity


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim typecar As Integer
            Dim daysrented As Integer
            Dim mile As Integer
            Dim insurance As Integer
            Dim tc As Integer
            daysrented = Val(TextBox1.Text)
            mile = Val(TextBox2.Text)
            tc = ComboBox1.SelectedIndex
            Select Case tc
                Case 0
                    typecar = 1
                Case 1
                    typecar = 2
                Case 2
                    typecar = 3
                Case 3
                    typecar = 4
            End Select

            If RadioButton1.Checked = True Then
                insurance = 1
            End If
            If RadioButton2.Checked = True Then
                insurance = 2
            End If

            Dim c_rental As Car_Rental
            c_rental = New Car_Rental(typecar, daysrented, mile, insurance)
            TextBox3.Text = c_rental.compRent

        Catch err As ApplicationException
            Select Case err.Source
                Case "d"
                    ErrorProvider1.SetError(TextBox1, err.Message)
                Case "m"
                    ErrorProvider1.SetError(TextBox2, err.Message)
            End Select
        End Try
    End Sub
End Class

 

*CLASS

Public Class Car_Rental
    Private type As Integer
    Private days As Integer
    Private mil As Integer
    Private ins As Integer
    Private rental As Integer

    Public Sub New()
        type = 0
        days = 0
        mil = 0
        ins = 0
        rental = 0
    End Sub

    Public Sub New(ByVal tcar As Integer, ByVal drent As Integer, ByVal mleage As Integer, ByVal insranz As Integer)
        type = tcar
        DaysRented = drent
        Mileage = mleage
        ins = insranz
        rental = 0
    End Sub


    Public Property DaysRented() As Integer
        Get
            Return days
        End Get
        Set(ByVal value As Integer)
            If value >= 1 And value <= 100000 Then
                days = value
            Else
                Dim Ex As New ApplicationException("Invalid Input")
                Ex.Source = "d"
                Throw Ex
            End If
        End Set
    End Property

    Public Property Mileage() As Integer
        Get
            Return mil
        End Get
        Set(ByVal value As Integer)
            If value >= 1 And value <= 100000 Then
                mil = value
            Else
                Dim Ex As New ApplicationException("Invalid Input")
                Ex.Source = "m"
                Throw Ex
            End If
        End Set
    End Property

    Public Function compRent() As Integer
        Dim bcharge As Integer
        Dim mcharge As Integer
        Select Case type
            Case 1
                bcharge = days * 8
                mcharge = mil * 0.06
            Case 2
                bcharge = days * 10
                mcharge = mil * 0.08
            Case 3
                bcharge = days * 15
                mcharge = mil * 0.12
            Case 4
                bcharge = days * 20
                mcharge = mil * 0.16
        End Select

        If ins = 1 Then
            rental = (((bcharge + mcharge) * 0.2) + (bcharge + mcharge))
        End If
        If ins = 2 Then
            rental = ((bcharge + mcharge) + (days * 4))
        End If
        Return rental
    End Function

End Class
 


Posted by shazzo.nica at 6:28 PM WST

Codes - TaxDue (with Class)
Mood:  cool
Topic: Lab Activity


 

Public Class Form1
    Dim ex As Integer
    Dim no As Integer
    Dim add As Integer
    Dim tax_in As Integer
    Dim due As Double


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim gpay As Integer
            Dim stat As Integer
            Dim nodep As Integer
            Dim i As Integer
            gpay = Val(TextBox1.Text)
            If RadioButton1.Checked = True Then
                stat = 1
            End If
            If RadioButton2.Checked = True Then
                stat = 2
                i = ComboBox1.SelectedIndex
                Select Case i
                    Case 0
                        nodep = 1
                    Case 1
                        nodep = 2
                    Case 2
                        nodep = 3
                    Case 3
                        nodep = 4
                    Case 4
                        nodep = 5
                    Case 5
                        nodep = 6
                    Case 6
                        nodep = 7
                    Case 7
                        nodep = 8
                    Case 8
                        nodep = 9
                End Select
            End If
            If RadioButton3.Checked = True Then
                stat = 3
            End If
            If RadioButton4.Checked = True Then
                stat = 4
            End If
            
            Dim taxdue As Tax_due
            taxdue = New Tax_due(gpay, stat, nodep)
            TextBox2.Text = taxdue.compTax
        Catch err As ApplicationException
            Select Case err.Source
                Case "g"
                    ErrorProvider1.SetError(TextBox1, err.Message)
            End Select
        End Try
    End Sub

End Class

 

 

*CLASS

Public Class Tax_due
    Private g_pay As Integer
    Private status As Integer
    Private no_dep As Integer
    Private taxdue As Double

    Public Sub New()
        g_pay = 0
        status = 0
        no_dep = 0
        taxdue = 0
    End Sub

    Public Sub New(ByVal gp As Integer, ByVal st As Integer, ByVal dep As Integer)
        GrossPay = gp
        status = st
        no_dep = dep
        taxdue = 0

    End Sub

    Public Property GrossPay() As Integer
        Get
            Return g_pay
        End Get
        Set(ByVal value As Integer)
            If value >= 1 And value <= 100000 Then
                g_pay = value
            Else
                Dim Ex As New ApplicationException("Invalid Input")
                Ex.Source = "g"
                Throw Ex
            End If
        End Set
    End Property


    Public Function compTax() As Integer
        Dim ex As Integer
        Dim add As Integer
        Dim tax As Integer
        If status = 1 Then
            ex = 9000
        ElseIf status = 2 Then
            ex = 12000
            Select Case no_dep
                Case 1
                    add = 7000
                Case 2
                    add = 14000
                Case 3
                    add = 21000
                Case Else
                    add = 28000
            End Select
        ElseIf status = 3 Then
            ex = 7500
        Else
            ex = 6000
        End If

        tax = (g_pay - (ex + add))

        If tax < 54 Then
            taxdue = 0
        ElseIf tax > 53 And tax < 158 Then
            taxdue = 0 + (0.12 * (tax - 54))
        ElseIf tax > 157 And tax < 365 Then
            taxdue = 12.45 + (0.15 * (tax - 158))
        ElseIf tax > 364 And tax < 554 Then
            taxdue = 43.53 + (0.19 * (tax - 365))
        ElseIf tax > 553 And tax < 846 Then
            taxdue = 79.44 + (0.25 * (tax - 554))
        ElseIf tax > 845 And tax < 1069 Then
            taxdue = 152.44 + (0.3 * (tax - 846))
        ElseIf tax > 1068 And tax < 1273 Then
            taxdue = 219.34 + (0.34 * (tax - 1069))
        Else
            taxdue = 288.7 + (0.37 * (tax - 1273))
        End If

        Return taxdue

    End Function
End Class
 


Posted by shazzo.nica at 5:58 PM WST
Updated: Wednesday, February 27, 2008 6:20 PM WST

Wednesday, February 20, 2008

5th Entry
Mood:  energetic
Now Playing: Shut Up and Drive by Rihanna
Topic: 4GL Class

 

    I learned about the basic stuffs about Visual Basic 2005. The presentation was cool eventhough I quite had a hard time understanding it because of 2 things. The monitor was not big enough and the speakeron the presentation was talking fast and he has an accent! Anyway, that didn't keep me from getting the important points of that presentation. My mind was refreshed. I remembered how to start using Visual Basic. Though I have forgotten specific things such as the name of icons. But all in all, I was doing just fine.

 

    I remembered hot to use the toolbox, the solution explorer and properties of a certain control. I remembered how to make a simple program. I stopped last semester that's why it's somewhat hard for me to recall such things. I experimented with the different controls found in VB. I even tried using all the things found in the toolbox. I was really curious what combobox and other things in the toolbox looked like.

 

    I also experimented with the toolbar. There were lots of buttons and I almost used all of them just for the sake of satisfying my curiosity. I enjoyed designing my form, changing the color of buttons, font style, size and color. But in the end, I settled for plain black and white (my favorite!). I was able to use the Text, Val and Focus().


Posted by shazzo.nica at 6:00 PM WST
Updated: Wednesday, February 20, 2008 6:10 PM WST

4th Entry
Mood:  silly
Now Playing: Adrienne by The Calling
Topic: 4GL Class

 

    I enjoyed doing all the lab activities. Our professor introduced several new features of Visual Basic 2005. We made use of the KeyTrapping that was introduce to us in our last lecture. I really think that this feature is very much necessary when making an application. He also introduced a feature which can replaced the message box. The advantage of it is an icon will appear near the control where an error is committed. And then the rror message will only appear when you will put the cursor over it. Thhat certain feature is called an ErrorProvider. Using it was quite simple but the irony is that I can vaguely remember the syntax of that control.

 

    I already finished our last graded lab activity for the midterm. But unfortunately, I have a back log. My second to the last lab activity is not finished yet. Supposed to be, I was already finished but our instructor added another requirement which was the enabling of the button whenever a reservation was cancelled. I don't know how to do that yet. Hopefullu, I'll be able to figure it out before our next lab session which would be next week. I don't know if my program isright but so far I've managed to meet all the requirements except for the last one. My codes are quite long because I am used to writing codes my own style. I don't know if it's right but what matters to me is it's functioning the way it is supposed to.


Posted by shazzo.nica at 5:37 PM WST
Updated: Wednesday, February 20, 2008 5:56 PM WST

Friday, February 15, 2008

3rd Entry
Mood:  cool
Now Playing: Umbrella by Mandy Moore
Topic: 4GL Class

    I've learned a lot about Visual Basic 2005 but I can't remember them all. I remember them whenever I'm infront of a computer and in the process of making a program.

    In the past few meetings that we had in our 4GL class, our instructor introduced controls that were not even familiar to me such as the DateTimePicker and the ToolStripMenu. Adding menus on our form wasn't new to me anymore but I don't know it well. (Or maybe I did and I've just forgotten all about it.) Sir Pasamonte, in my File Org. class, already introduced that control though it's still quite different because we were using a different version of VB during that time.

    Our lesson in the past few days mede me understand VB better. Our instructor taught us different things about each control that we used in all our lab activities.

    He also gave us several lab avtivities before the graded activity. Those lab avtivities served as a practice for me. All practice lab activities were all somewhat easy and simple. And when it some to the graded activity, oh well, THEY ARE NOT EASY! Believe me. All of them are difficult in their own ways. Some are somewhat easy but really very, very tricky.



But in general, I can say that I'm learning and I'M DEFINITELY ENJOYING.


Posted by shazzo.nica at 6:39 PM WST
Updated: Wednesday, February 20, 2008 6:15 PM WST

Newer | Latest | Older