It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

(newbie) Struggling with my console application.

Moderator: dafunkymunky

(newbie) Struggling with my console application.

Postby Proon on Sun Jun 05, 2011 12:50 pm

Hi, I'm coming to the end of my networking course at college and one of the last things I have to do is write a program in VB. To give you a quick background on the program, I work for my parents at 'Spheremania' (pushing people down hills in really big balls) and so I thought it would make things easier if I wrote a program for a purpose at work. The program essentially stores a users input. It's a health and safety check in a program. When you load the program you're presented with various options - some of which lead to an archive of past safety checks, and others which lead to forms for a new safety check.

However, I can't seem to get it to work. Specifically I can't get the program to save the data.

I'm actually getting various errors whenever I debug the program - and when I fix one error, another appears that wasn't there before. The line that appears to be causing most issue is the line that tells the program to 'FilePut' the data into the file because it is telling me to write 'FilePutObject'. I make the change and then when I debug the program again it tells me to change various variable-types (I'm not sure of the terminology; e.g. Long, String, Char, Integer etc.) on my recording data.

Heres the top part of my code (as you can see I will have 2 other Subs with the same problem). This is only a 3rd of the code, I can show you the rest if you need, but I think if I find out what's wrong here then I should be able to fix the rest myself.



[spoiler]Imports System.IO

Module Module1
Structure VehicleRecordType
<VBFixedString(10)> Public VehicleDt As String
<VBFixedString(10)> Public VehicleIDNO As String
<VBFixedString(10)> Public VehicleComp As String
<VBFixedString(255)> Public VehicleNotes As String

End Structure
Dim VehicleRec As VehicleRecordType
Dim Vehiclefilename As String = "C:\Documents and Settings\m.archer2101\Dropbox\Year 2\Will\IT Project\Tasks\Part C\VehicleRecords.dat"

Structure SphereRecordType
<VBFixedString(10)> Public SphereDt As String
<VBFixedString(6)> Public SphereIDNO As String
<VBFixedString(3)> Public SphereComp As String
<VBFixedString(255)> Public SphereNotes As String

End Structure
Dim SphereRec As SphereRecordType
Dim Spherefilename As String = "C:\Documents and Settings\m.archer2101\Dropbox\Year 2\Will\IT Project\Tasks\Part C\SphereRecords.dat"


Structure OtherRecordType
<VBFixedString(10)> Public OtherDt As String
<VBFixedString(6)> Public OtherIDNO As String
<VBFixedString(3)> Public OtherComp As String
<VBFixedString(255)> Public OtherNotes As String

End Structure
Dim OtherRec As OtherRecordType
Dim Otherfilename As String = "C:\Documents and Settings\m.archer2101\Dropbox\Year 2\Will\IT Project\Tasks\Part C\OtherRecords.dat"




Sub Main()
Dim Reply As Integer


Console.BackgroundColor = ConsoleColor.White
Console.ForegroundColor = ConsoleColor.Black

Vehiclefilename = "C:\Users\Matty\Dropbox\Year 2\Will\IT Project\Tasks\Part C\VehicleRecords.dat"
FileOpen(1, Vehiclefilename, OpenMode.Random, , , Len(VehicleRec))
Spherefilename = "C:\Users\Matty\Dropbox\Year 2\Will\IT Project\Tasks\Part C\SphereRecords.dat"
FileOpen(2, Spherefilename, OpenMode.Random, , , Len(SphereRec))
Otherfilename = "C:\Users\Matty\Dropbox\Year 2\Will\IT Project\Tasks\Part C\OtherRecords.dat"
FileOpen(3, Otherfilename, OpenMode.Random, , , Len(OtherRec))




Do
Console.Clear()
Console.SetCursorPosition(20, 6)
Console.WriteLine("Main menu")
Console.SetCursorPosition(20, 8)
Console.WriteLine("1 Show Vehicle Checklist")
Console.SetCursorPosition(20, 9)
Console.WriteLine("2 Show Sphere Checklist")
Console.SetCursorPosition(20, 10)
Console.WriteLine("3 Show Other Checklist")
Console.SetCursorPosition(20, 11)
Console.WriteLine("4 Show Previous Vehicle Records")
Console.SetCursorPosition(20, 12)
Console.WriteLine("5 Show Previous Sphere Records")
Console.SetCursorPosition(20, 13)
Console.WriteLine("6 Show Previous Other Records")
Console.SetCursorPosition(20, 16)
Console.Write("Enter Selection:")
Reply = Console.ReadLine()


If Reply = 1 Then
VehicleChecklist()
ElseIf Reply = 2 Then
SphereChecklist()
ElseIf Reply = 3 Then
OtherChecklist()
ElseIf Reply = 4 Then
PreviousVehicleRecords()
ElseIf Reply = 5 Then
PreviousSphereRecords()
ElseIf Reply = 6 Then
PreviousOtherRecords()
End If
Loop Until Reply <> 7

FileClose(1)
FileClose(2)
FileClose(3)

Console.ReadKey()

End Sub

Sub VehicleChecklist()

Dim Found As Boolean
Dim Counter As Integer
Dim LineCount As Integer
Dim ROGUEVALUE As Integer
Dim ListMax = 2
Dim newVehicleDt As String
Dim newVehicleIDNO As String
Dim newVehicleComp As String
Dim newVehicleNotes As String
Dim RecNo As String



Console.Clear()
Console.WriteLine()
Console.WriteLine("{0,45}", "Spheremania Ltd")
Console.WriteLine("{0,46}", "Vehicle Checklist")

Console.SetCursorPosition(3, 5)
Console.Write("Employee Name:")
Console.SetCursorPosition(40, 5)
Console.Write("Date:")


Console.WriteLine()
Console.WriteLine()
Console.WriteLine("{0,10}", " -----------------------------------------------------------------------------")
Console.WriteLine("{0,8}{1,25}{2,25}{3,15}", "ID No.", "Description", "Completed", "Notes")
Console.WriteLine("{0,10}", " -----------------------------------------------------------------------------")


Console.SetCursorPosition(17, 5)
Console.ReadLine()
Console.SetCursorPosition(45, 5)
newVehicleDt = Console.ReadLine()


Console.SetCursorPosition(3, 10)
Console.Write("")
newVehicleIDNO = Console.ReadLine()
Console.SetCursorPosition(20, 10)
Console.Write("A check to see whether")
Console.SetCursorPosition(20, 11)
Console.Write("the vehicle transporting")
Console.SetCursorPosition(20, 12)
Console.Write("the customers is safe.")
Console.ReadLine()
Console.SetCursorPosition(50, 10)
Console.Write("")
newVehicleComp = Console.ReadLine()
Console.SetCursorPosition(64, 10)
Console.Write("")
newVehicleNotes = Console.ReadLine()


RecNo = newVehicleDt
RecNo = newVehicleIDNO
RecNo = newVehicleComp
RecNo = newVehicleNotes


VehicleRec.VehicleDt = newVehicleDt
VehicleRec.VehicleIDNO = newVehicleIDNO
VehicleRec.VehicleComp = newVehicleComp
VehicleRec.VehicleNotes = newVehicleNotes

FilePutObject(1, VehicleRec, RecNo)
Console.WriteLine("Record {0} written to file", RecNo)


Console.WriteLine()
Console.Write("Press a key to return to Main Menu")
Console.ReadKey()


End Sub[/spoiler]



Thanks again, Dave.
Proon
 
Posts: 1
Joined: Sun Jun 05, 2011 12:48 pm

Who is online

Users browsing this forum: No registered users and 5 guests