I'm having a terrible time understanding this for some reason. I'm supposed to be creating a Class to "Define four private instance variables to represent each property value
Use the above variables to define a constructor
Establish a property to correspond with each variable which allows user to set or get the variable's value"

For some reason, I'm just really confused on this. Any tips that anyone might have would be SO fantastic. Here's my code so far (hoping that it is right):

Public Class AccountInformationForm

   Private clientObject As Client
   Private clients(0 To 7) As Client     ' Client object
   Private position As Integer = 0 ' current account

   ' create array of Client objects
   Private Sub AccountInformationForm_Load(ByVal sender As _
      System.Object, ByVal e As System.EventArgs) _
      Handles MyBase.Load

      Dim count As Integer ' counter variable

      ' array of first names
      Dim firstName() As String = _
         New String() {"John", "Sarah", "Jack", "Adam", "Diane", _
            "David", "Kristin", "Jennifer"}

      ' array of last names
      Dim lastName() As String = _
         New String() {"Blue", "White", "Red", "Brown", _
            "Yellow", "Black", "Green", "Orange"}

      'array of account numbers 
      Dim account() As Integer = _
         New Integer() {1234652, 1234666, 1234678, 1234681, _
            1234690, 1234770, 1234787, 1234887}

      ' array of account balances
      Dim balance() As Decimal = _
         New Decimal() {Convert.ToDecimal(1000.78), _
            Convert.ToDecimal(2056.24), Convert.ToDecimal(978.65), _
            Convert.ToDecimal(990.0), Convert.ToDecimal(432.75), _
            Convert.ToDecimal(780.78), Convert.ToDecimal(4590.63), _
            Convert.ToDecimal(7910.11)}

      ' loop and create 10 Client objects
      For count = 0 To clients.GetUpperBound(0)

         ' create new object and store into Client array
         clients(count) = New Client(firstName(count), _
            lastName(count), account(count), _
            balance(count))
      Next

   End Sub ' AccountInformationForm_Load

   ' display next object
   Private Sub nextButton_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles nextButton.Click

      position += 1 ' increment position

      ' if position is last (top) object
      If position > clients.GetUpperBound(0) Then
         position = 0    ' set to first position in array
         DisplayInformation() ' display information
      Else
         DisplayInformation()
      End If

   End Sub ' nextButton_Click

   ' display previous object
   Private Sub preveiousButton_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles previousButton.Click

      position -= 1 ' decrement position

      ' if position is last (bottom) object
      If position < 0 Then

         ' set to last position in array
         position = clients.GetUpperBound(0)
         DisplayInformation()
      Else
         DisplayInformation() ' display information
      End If

   End Sub ' previousButton_Click

   ' display information
   Private Sub DisplayInformation()

      ' use Position as index for each object
      firstTextBox.Text = clients(position).First
      lastTextBox.Text = clients(position).Last
      accountTextBox.Text = _
         Convert.ToString(clients(position).Account)

      ' format as currency
      balanceTextBox.Text = _
         String.Format("{0:C}", clients(position).Balance)

   End Sub ' DisplayInformation
End Class ' AccountInformationForm
Public Class Client

   Private First As String
   Private Last As String
   Private Account As Integer
   Private Balance As Decimal

End Class

Okay, I'm figuring more out (I think). :) But if someone could find it in their heart to help me out with a couple of questions, that would be great!


Here's what I have so far:

Public Class Client

   Private firstValue As String
   Private lastValue As String
   Private accountValue As Integer
   Private balanceValue As Decimal

   Public Sub New(ByVal frst As Integer, ByVal lst As Integer, ByVal acct As Integer, _
      ByVal bal As Integer)

      First = frst
      Last = lst
      Account = acct
      Balance = bal
   End Sub

   Public Property First() As String
      Get
         Return firstValue
      End Get
      Set(ByVal value As String)
         If (value = "") Then
            MessageBox.Show("Please enter a first name.", MessageBoxButtons.OK, _
               MessageBoxIcon.Information)
         End If
      End Set
   End Property

   Public Property Last() As String
      Get
         Return lastValue
      End Get
      Set(ByVal value As String)

      End Set
   End Property

   Public Property Account() As Integer
      Get
         Return accountValue
      End Get
      Set(ByVal value As Integer)

      End Set
   End Property

   Public Property Balance() As Decimal
      Get
         Return balanceValue
      End Get
      Set(ByVal value As Decimal)

      End Set
   End Property
End Class

and...

Public Class AccountInformationForm

   Private clientObject As Client
   Private clients(0 To 7) As Client     ' Client object
   Private position As Integer = 0 ' current account

   ' create array of Client objects
   Private Sub AccountInformationForm_Load(ByVal sender As _
      System.Object, ByVal e As System.EventArgs) _
      Handles MyBase.Load

      Dim count As Integer ' counter variable

      ' array of first names
      Dim firstName() As String = _
         New String() {"John", "Sarah", "Jack", "Adam", "Diane", _
            "David", "Kristin", "Jennifer"}

      ' array of last names
      Dim lastName() As String = _
         New String() {"Blue", "White", "Red", "Brown", _
            "Yellow", "Black", "Green", "Orange"}

      'array of account numbers 
      Dim account() As Integer = _
         New Integer() {1234652, 1234666, 1234678, 1234681, _
            1234690, 1234770, 1234787, 1234887}

      ' array of account balances
      Dim balance() As Decimal = _
         New Decimal() {Convert.ToDecimal(1000.78), _
            Convert.ToDecimal(2056.24), Convert.ToDecimal(978.65), _
            Convert.ToDecimal(990.0), Convert.ToDecimal(432.75), _
            Convert.ToDecimal(780.78), Convert.ToDecimal(4590.63), _
            Convert.ToDecimal(7910.11)}

      ' loop and create 10 Client objects
      For count = 0 To clients.GetUpperBound(0)

         ' create new object and store into Client array
         clients(count) = New Client(firstName(count), _
            lastName(count), account(count), _
            balance(count))
      Next

   End Sub ' AccountInformationForm_Load

   ' display next object
   Private Sub nextButton_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles nextButton.Click

      position += 1 ' increment position

      ' if position is last (top) object
      If position > clients.GetUpperBound(0) Then
         position = 0    ' set to first position in array
         DisplayInformation() ' display information
      Else
         DisplayInformation()
      End If

   End Sub ' nextButton_Click

   ' display previous object
   Private Sub preveiousButton_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles previousButton.Click

      position -= 1 ' decrement position

      ' if position is last (bottom) object
      If position < 0 Then

         ' set to last position in array
         position = clients.GetUpperBound(0)
         DisplayInformation()
      Else
         DisplayInformation() ' display information
      End If

   End Sub ' previousButton_Click

   ' display information
   Private Sub DisplayInformation()

      ' use Position as index for each object
      firstTextBox.Text = clients(position).First
      lastTextBox.Text = clients(position).Last
      accountTextBox.Text = _
         Convert.ToString(clients(position).Account)

      ' format as currency
      balanceTextBox.Text = _
         String.Format("{0:C}", clients(position).Balance)

   End Sub ' DisplayInformation
End Class ' AccountInformationForm

In the Client Class, what does the following code do?

Public Sub New(ByVal frst As Integer, ByVal lst As Integer, ByVal acct As Integer, _
      ByVal bal As Integer)

      First = frst
      Last = lst
      Account = acct
      Balance = bal
   End Sub

Also, the Debugger is yelling rather profusely about the message box I'm trying to use here. Why?

Public Property First() As String
      Get
         Return firstValue
      End Get
      Set(ByVal value As String)
         If (value = "") Then
            MessageBox.Show("Please enter a first name.", MessageBoxButtons.OK, _
               MessageBoxIcon.Information)
         End If
      End Set
   End Property

Your class should be:

Class Client
    Private Firstvalue As String = ""
    Private Lastvalue As String = ""
    Private accountvalue As Integer
    Private balancevalue As Decimal

    Public Sub New(ByVal First As String, ByVal Last As String, ByVal account As Integer, ByVal balance As Decimal)
        Firstvalue = First
        Lastvalue = Last
        accountvalue = account
        balancevalue = balance

    End Sub

    Public Property First() As String
        Get
            Return firstValue
        End Get
        Set(ByVal value As String)
            If (value = "") Then

            End If
        End Set
    End Property

    Public Property Last() As String
        Get
            Return lastValue
        End Get
        Set(ByVal value As String)

        End Set
    End Property

    Public Property account() As Integer
        Get
            Return accountvalue
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property

    Public Property balance() As Decimal
        Get
            Return balancevalue
        End Get
        Set(ByVal value As Decimal)

        End Set
    End Property
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.