locked
Loop RRS feed

  • Question

  • User-889200019 posted

    Hi there here is my homework and i have no idea how to do it  , could anyone can help me please? :)

     

    You have been provided with a program called “****”.  This program links to an Access database and reads a table called Swap.  In a finished swap shop it may be a good idea to categorise the swaps, for example.

    Computer

    Equipment

    CDs

     Books

    Clothing

     Office Supplies

    Furniture

    Kitchen Equipment

     Musical

    Instruments

    Bedding

     DIY

    The finished program needs to display the first five swap categories when the button display is pressed.



    Partial Class _Default
        Inherits System.Web.UI.Page
        Dim SwapCounter As Integer
    
        Protected Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
           
    ' PUT YOUR CODE HERE!
           
     lstTop5.Items.Add(GetTopSwaps)
        End Sub
    
        'you do not need to worry about this code yet
        'however it is worth trying to get your head around it
        'as you will have to sooner or later
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            'when the page loads
            'if it is the first time
            If IsPostBack = False Then
                'initialise the swap counter
                SwapCounter = 0
            Else
                'otherwise get the value from the session object
                SwapCounter = Session("SwapNo")
            End If
        End Sub
    
    
        Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
            'store the value of the swap counter
            Session("SwapNo") = SwapCounter
        End Sub
    
        Function GetTopSwaps() As String
            'this function returns the swap indicated by swap counter
            'swap counter is incremented by one
            'if all the swaps have been used swap counter is reset to zero
            'open a connection to the database
            Dim Swaps As New DatabaseTable("swaps.mdb", "select * from swap", "#PN", "#PW")
            'get the swap pointed to by the swap counter
            Dim ASwap As String = Swaps.RecordNumber(SwapCounter).Item("Swap")
            'increment the swap counter
            SwapCounter += 1
            'if all swaps are read
            If SwapCounter = Swaps.Count Then
                'start at swap zero
                SwapCounter = 0
            End If
            'return the swap
            Return ASwap
        End Function
    End Class

     

    Thanks !

     

    Wednesday, February 16, 2011 1:39 PM

Answers

  • User-1102123764 posted

    Hi there here is my homework and i have no idea how to do it  ,

    Hi,

    I think we have to try our best to do our homework by ourself. Please search on the MSDN and internet. I think you will get what you want.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 18, 2011 4:04 AM