Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8609805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:58:10+00:00 2026-06-12T03:58:10+00:00

The following is the code which I am using for creating a two dimensional

  • 0

The following is the code which I am using for creating a two dimensional array

Public Class frmGrades
Private Score As Dictionary(Of String, String) = New Dictionary(Of String, String)

Private Sub cmdApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdApply.Click
    Static intNumber As Integer
    ReDim Preserve Score(1, intNumber)
    Score(0, intNumber) = txtStudent.Text
    Score(1, intNumber) = txtGrade.Text
    hsbStudent.Maximum = intNumber
    hsbStudent.Value = intNumber
    intNumber = intNumber + 1
    txtGrade.Clear()
    txtStudent.Clear()
    txtStudent.Focus()

End Sub

Private Sub hsbStudent_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles hsbStudent.Scroll
    txtStudent.Text = Score(0, hsbStudent.Value)
    txtGrade.Text = Score(1, hsbStudent.Value)

End Sub

Private Sub cmdFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFirst.Click
    txtStudent.Text = Score(0, hsbStudent.Minimum)
    txtGrade.Text = Score(1, hsbStudent.Minimum)

End Sub

Private Sub cmdLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLast.Click
    txtStudent.Text = Score(0, hsbStudent.Maximum)
    txtGrade.Text = Score(1, hsbStudent.Maximum)
End Sub

**Private Sub CmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdEdit.Click

    If Score.ContainsKey(txtStudent.Text) Then
        Score.Item(txtStudent.Text) = txtGrade.Text
    Else
        Score.Add(txtStudent.Text, txtGrade.Text)
    End If
End Sub

End Class**

Now I would like to edit the grade text box which should also change the grade in the array. Any idea on how could this be done.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:58:12+00:00Added an answer on June 12, 2026 at 3:58 am

    UPDATE:

    OK, I see the code has a little more now and the problem is more clear as well as the need for a different approach. I rewrote your code. See if this works for you:

    Public Class frmGrades
    
        Public Class StudentGrade
            Public Name As String
            Public Grade As String
        End Class
    
        Private Score As List(Of StudentGrade) = New List(Of StudentGrade)
    
        Private Sub cmdApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdApply.Click
    
            AddStudent()
    
        End Sub
    
        Private Sub hsbStudent_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles hsbStudent.Scroll
            Update(hsbStudent.Value - 1) 'lists are zero-based
        End Sub
    
        Private Sub cmdFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFirst.Click
            Update(0)
        End Sub
    
        Private Sub cmdLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLast.Click
            Update(hsbStudent.Maximum - 1)
        End Sub
        Private Sub AddStudent()
            Dim nm As New StudentGrade
            nm.Name = txtStudent.Text
            nm.Grade = txtGrade.Text
            Score.Add(nm)
    
            hsbStudent.Minimum = 1
            hsbStudent.Maximum = Score.Count 
            hsbStudent.Value = Score.Count 
    
            txtGrade.Clear()
            txtStudent.Clear()
            txtStudent.Focus()
        End Sub
        Private Sub Update(i As Integer)
            txtStudent.Text = Score(i).Name
            txtGrade.Text = Score(i).Grade
        End Sub
        Private Sub CmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdEdit.Click
    
            Dim index As Integer = -1, cnt As Integer = 0
    
            For Each nm As StudentGrade In Score
                If nm.Name.ToLower = txtStudent.Text.ToLower Then
                    index = cnt
                    Exit For
                End If
                cnt += 1
            Next
    
            If index = -1 Then
                AddStudent()
            Else
                Score(index).Name = txtStudent.Text
                Score(index).Grade = txtGrade.Text
                hsbStudent.Value = index + 1
            End If
    
        End Sub
    
    End Class
    

    With this code you can expand the class StudentGrade to contain whatever you need to store. The list, contrary to dictionary, allow you to use index values as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code which will generate a wav file which contains a
Given the following lines of code which is using JQTOUCH: $('#customers').bind('pageAnimationEnd', function(e, info){ if
I have the following code which outputs an object to an XML file: using
I am using the following code to determine which key is pressed by the
I have a javascript code using which I want to accomplish the following .
I'm using the following code to load some sounds depending on which button a
I'm using he following code the call a CFC which returns auto-suggest results through
I'm using the following code to post to the server which is then sent
I'm using the following code in CoffeeScript: if elem in my_array do_something() Which compiles
I am using Dmxzones Advanced HTML Editor 3 which inserts the following code: <textarea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.