[Solved] deleting element from structure!

I need to delete only one element from structure!

Page 1 of 1

2 Replies - 3036 Views - Last Post: 25 April 2010 - 11:18 AM Rate Topic: -----

#1 samoi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 12-February 09

[Solved] deleting element from structure!

Posted 25 April 2010 - 12:59 AM

Hello my friends.
I'm running into deep trouble with this structure variable!

this is the structure
 Structure StuRec
        Dim strName As String
        Dim strMNum As String
        Dim ArrScores() As Decimal
        Dim decAvg As Decimal
        Dim strLetter As String
    End Structure


dim gBook(20) as StuRec

' #
' ## handling and filling gBook() with 14 records let's say!
' #

' #By now gBook() has 14 records!

' #I need to delete one record of gBook(). Say I need to delete gBook(3) for example!

' #I did this
dim Temp() as StuRec

For i as integer = 0 To 14
      if i = 3 then continue For
      temp(i).strName = gBook(i).strName
      'strMNum as well and the others
      'ArrScore(0) is number of scores that student got!
      temp(i).ArrScore(0) = gBook(i).ArrScore(0)
      For c as integer = 1 To gBook(i).ArrScore(0)
      
      temp(i).ArrScore(c) = gBook(i).ArrScore(c)
      
      Next c
Next i




the ArrScores() has maximum elements of 10 subscripts

so i need to delete one recored of them. but it doesn't really seems to be working :S

Your help is much much appreciated !

This post has been edited by samoi: 25 April 2010 - 11:20 AM


Is This A Good Question/Topic? 0
  • +

Replies To: [Solved] deleting element from structure!

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,178
  • Joined: 02-July 08

Re: [Solved] deleting element from structure!

Posted 25 April 2010 - 02:59 AM

Use a List(Of T) instead of array.
Dim myStrucList As New List(Of StuRec)
'add the elements you need
'then to delete
myStrucList.RemoveAt(3)

Was This Post Helpful? 2
  • +
  • -

#3 samoi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 12-February 09

Re: [Solved] deleting element from structure!

Posted 25 April 2010 - 11:18 AM

View Posthawkvalley1, on 25 April 2010 - 01:59 AM, said:

Use a List(Of T) instead of array.
Dim myStrucList As New List(Of StuRec)
'add the elements you need
'then to delete
myStrucList.RemoveAt(3)

Wow :)
That really fixed the problem!
Thank you my friend!
I really appreciate that.
:)
Thumb UP!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1