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

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

$
0
0
Hello,

I am new programmer, I have a created a program that can read text file splitting the value on it, actually I have done it but there is a bugs which I cannot proceed to run the program.

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 what Im done in Module:

Code:

Option Explicit On
Option Infer Off
Option Strict On

Imports System.IO
Imports System.Runtime.CompilerServices

Module Module1
    '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 Funsction:

Code:

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

The error shows in function in "(source.Count(Of BookInfo)" says: Overload resolution failed because no accessible 'Count' accept this number of types of arguments.

Can anyone help me this.

Best Regards,

John

Viewing all articles
Browse latest Browse all 27389

Trending Articles



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