Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27186

VS 2010 [RESOLVED] .Net Module fixing bugs (Reading text file)

$
0
0
Attachment 94103

Hello,

I am new Programmer, I have done a simple program that can read text file, I am having a little bug in the code which I cannot proceed.

Here is my text file to read:

0#Goodnight Moon (Board Book)#Margaret Wise Brown#HarperCollins Publishers#0694003611#8.09
1#The Very Hungry Caterpillar (Board Book)#Eric Carle#Penguin Group (USA)#0399226907#7.91
2#The Going to Bed Book#Sandra Boynton#Little Simon#0671449028#5.39
3#The Artist Who Painted a Blue Horse#Eric Carle#Penguin Group (USA)#0399257136#9.89
4#If You Give a Cat a Cupcake#Laura Numeroff#HarperCollins Publishers#0060283246#10.36

Here is my Module:

Code:

'declaration of BookInfo structure
    Public Structure BookInfo
        Public bookID As String
        Public bookTitle As String
        Public bookAuthor As String
        Public bookPublisher As String
        Public bookISBN As String
        Public bookPrice As Decimal
    End Structure

here is my Function:

Code:

'function that accept a path to the book db file,
    'load the information in the file into an array of BookInfo structure,
    ' and return the array
    Public Function LoadBookInfo(ByVal bookdbFileName As String) As BookInfo()
        Dim source As BookInfo() = New BookInfo(5 - 1) {}
        Dim reader As StreamReader = File.OpenText(bookdbFileName)
        Dim num2 As Integer = (source.Count(Of BookInfo)() - 1)
        Dim i As Integer = 0
        Do While (i <= num2)
            Dim strArray As String() = reader.ReadLine.Split(New Char() {"#"c})
            source(i).bookID = strArray(0)
            source(i).bookTitle = strArray(1)
            source(i).bookAuthor = strArray(2)
            source(i).bookPublisher = strArray(3)
            source(i).bookISBN = strArray(4)
            source(i).bookPrice = Convert.ToDecimal(strArray(5))
            i += 1
        Loop
        reader.Close()
        Return source

    End Function

The error is "(source.Count(Of BookInfo)()" says that 'Overload resolution failed because no accessible 'Count' accepts this number type of arguments
Please guide me..

Regards,

Ryan

Viewing all articles
Browse latest Browse all 27186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>