I can't figure out why this won't work. Any help would be appreciated!
Imports System
Imports System.IO
Imports System.Text
Module Module1
Dim Notes As String
Dim Choice As String
Dim barcode As String
Dim barcodeinput As String
Dim No As Integer
Dim Notes1 As String
Dim Notes2 As String
Dim Notes3 As String
Dim ITEM As String
Dim purchasenumber As Integer
Dim Done As String
Dim list As Array
Dim Cost As Array
Dim NumberBrought As Array
Dim itemname As Array
Dim b As Integer
Sub main()
Console.WriteLine("Please chose an option")
Console.WriteLine("1:Create/overwrite and update file")
Console.WriteLine("2:Read file")
Console.WriteLine("3:Order from file")
Console.WriteLine("Input choice number")
Choice = Console.ReadLine()
If Choice = "1" Then
Create_File()
ElseIf Choice = "2" Then
Read_File()
ElseIf Choice = "3" Then
Order()
End If
main()
End Sub
Sub Create_File()
Dim fileLoc As String = "\\lisa\12VincentC$\My Documents\New testy thing of doom\Barcode Shopping System.txt"
'Create or overwrite the file.
Dim fs As FileStream = File.Create(fileLoc)
fs.Close()
Dim i As Integer
Dim aryText(5) As String
aryText(0) = "23147120 , Basic Unit Pack , 9999999 , 0.20"
aryText(1) = "77321550 , Advanced Unit Pack , 9999999 , 0.50"
aryText(2) = "95678230 , Legendary Unit Pack , 9999999 , 1"
aryText(3) = "21559380 , Sacred Unit Pack , 999999 , 5"
aryText(4) = "24568970 , Event Pack , 1234 , 1"
aryText(5) = "09765430 , Sinlge doom unit , 1000 , 10"
Dim objWriter As New System.IO.StreamWriter(fileLoc, True)
For i = 0 To 5
objWriter.WriteLine(aryText(i))
Next
objWriter.Close()
Console.WriteLine("Complete")
main()
End Sub
Sub Read_File()
Dim fileLoc As String = "\\lisa\12VincentC$\My Documents\New testy thing of doom\Barcode Shopping System.txt"
Dim fileContents As String() = IO.File.ReadAllLines(fileLoc)
Dim x As Integer = fileContents.Count
Dim Barcode(x) As String
Dim Name(x) As String
Dim Quantity(x) As String
Dim Price(x) As String
Dim line As String()
For a = 0 To fileContents.Count - 1
line = fileContents(a).Split(New Char() {","c})
Barcode(a) = line(0)
Name(a) = line(1)
Quantity(a) = line(2)
Price(a) = line(3)
Next
For j = 0 To x - 1
Console.Write(Barcode(j) & ", ")
Console.Write(Name(j) & ", ")
Console.Write(Quantity(j) & ", ")
Console.Write(Price(j) & ", ")
Next
main()
End Sub
Sub Order()
Dim fileLoc As String = "\\lisa\12VincentC$\My Documents\New testy thing of doom\Barcode Shopping System.txt"
Dim fileContents As String() = IO.File.ReadAllLines(fileLoc)
Dim x As Integer = fileContents.Count
Dim Barcode(x) As String
Dim Name(x) As String
Dim Quantity(x) As String
Dim Price(x) As String
Dim line As String()
For a = 0 To fileContents.Count - 1
line = fileContents(a).Split(New Char() {","c})
Barcode(a) = line(0)
Name(a) = line(1)
Quantity(a) = line(2)
Price(a) = line(3)
Next
For j = 0 To x - 1
Console.Write(Barcode(j) & ", ")
Console.Write(Name(j) & ", ")
Console.Write(Quantity(j) & ", ")
Console.Write(Price(j) & ", ")
Next
Console.WriteLine("Input the product Barcode.")
barcodeinput = Console.ReadLine()
Dim found As Boolean
Dim barcodeplacement As Integer
Done = False
found = False
While Done = False
For L = 1 To 5
For b = 0 To 6
Console.WriteLine(" checking current barcode " & Barcode(b))
Console.WriteLine(barcodeinput)
If barcodeinput = Barcode(b) Then
found = True
End If
If found = True Then
barcodeplacement = b
Console.WriteLine("You have ordered" & Barcode(b))
Console.WriteLine(Name(barcodeplacement))
Console.WriteLine(Quantity(barcodeplacement))
Console.WriteLine(Price(barcodeplacement))
list(L) = Name(barcodeplacement)
Console.WriteLine("Please input how many you wish to buy")
purchasenumber = Console.Read()
itemname(L) = Barcode(barcodeplacement)
NumberBrought(L) = purchasenumber
Cost(L) = Price(barcodeplacement) * NumberBrought(L)
barcodeinput = Console.ReadLine
Console.WriteLine("Is that all? (Y/N)")
Choice = Console.ReadLine
If Choice = "N" Then
Order()
ElseIf Choice = "Y" Then
Console.WriteLine("Your reciept")
Done = True
End If
End If
Next
Next
If found = False Then
Console.WriteLine("Input not found")
Order()
End If
For L = 0 To 5
Console.WriteLine(itemname(L))
Console.WriteLine(NumberBrought(L))
Console.WriteLine(Cost(L))
Next
End While
End Sub
End Module