locked
Problem with Array RRS feed

  • Question

  • User1122355199 posted

    Hello Everyone and thanks for your help in advance.  I am trying to load an array from a dataview using the following code:

          

    Public Queue As String() = Nothing

            Dim Patients As DataView

            Dim Patient As DataRowView

            Dim QueueCounter As Integer = 0

            For Each Patient In Patients

                    Queue(QueueCounter) = Trim(Patient("Ins1CertNmbr").ToString)                

                    QueueCounter = QueueCounter + 1  

             Next

    However, I am receiving an error message of not set to an object.  I ahve verified that the datacolumn is not NULL, so that is not the issue.  I'm not sure why this error is happening. 

     

    Thursday, February 9, 2012 1:22 PM

Answers

  • User-1360095595 posted

    You need to initialize the Queue array. Currently you've set it to Nothing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 9, 2012 1:37 PM
  • User1835746656 posted

    Along the lines of what Metal said, you can set the string array to your dataview count -1. Something like (providing the dataview is filled already);

    Dim Queue(Patients.Count - 1) As String

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 9, 2012 1:51 PM

All replies

  • User-1360095595 posted

    You need to initialize the Queue array. Currently you've set it to Nothing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 9, 2012 1:37 PM
  • User1835746656 posted

    Along the lines of what Metal said, you can set the string array to your dataview count -1. Something like (providing the dataview is filled already);

    Dim Queue(Patients.Count - 1) As String

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 9, 2012 1:51 PM
  • User70677649 posted

    Dim label1 As New Label

    dim c as integer

    c=0

    For Each Patient In Patients

    label1.ID = "Label"& c.ToString

    label1.text= Trim(Patient("Ins1CertNmbr").ToString)  

    c=c+1

    Next

    Here you can get the value by refering the text property of

    label0.text

    label1.text

    label2.text so on....

    try.

     

     

    Wednesday, February 15, 2012 3:06 AM