The Student Room Group

Visual Basic project and wearing sanity

Ok, I've a project to complete in two weeks time. To cut a long rant short, the lecturer has left it until the last minute, didn't show up for one of the most crucial classes and really doesn't seem to be much of a teacher in the long run.

The project:

We have to create a program in Visual Basic for a small business to store information on their products. There should be three buttons on the first form: "product name", "product code" and "stock level".

We need to store the information (apparently) in a table (I have no idea how to visualize this) and the lecturer suggested that we use either string or records (What the frack is a record in VB?!)

As you can see, no amount of reading and research has developed my understanding of VB beyond how to click and drag a pretty button on a form, so any help on this would be greatly appreciated.

Scrap that - I would love you forever. That is, before I go insane.
Reply 1
franktherabbit
Ok, I've a project to complete in two weeks time. To cut a long rant short, the lecturer has left it until the last minute, didn't show up for one of the most crucial classes and really doesn't seem to be much of a teacher in the long run.

The project:

We have to create a program in Visual Basic for a small business to store information on their products. There should be three buttons on the first form: "product name", "product code" and "stock level".

We need to store the information (apparently) in a table (I have no idea how to visualize this) and the lecturer suggested that we use either string or records (What the frack is a record in VB?!)

As you can see, no amount of reading and research has developed my understanding of VB beyond how to click and drag a pretty button on a form, so any help on this would be greatly appreciated.

Scrap that - I would love you forever. That is, before I go insane.


Is this for uni or college? (most colleges teach vb.net, and a lot of unis do java)

Do you have a specification for this piece of work? Something which lists what the program must do exactly?
is this for AQA COMP4?

EDIT: and are we talking VB6 or VB.NET?
Reply 3
Are you doing OCR computing? Project on VB6?
I so the table where results will be shown would be in a list box, you have to create a random access file (len) etc erm and try to get a mark scheme it is much easier to understand than the spec.
My program is VERY simple, I have a home pagem customer page, and appointments page and the last two forms just add, edit and delete data. But if you are aiming for an A grade then you need to include stuff like search (to go through all files) and validation etc
Sorry couldnt help more, I find this project a pain in the ass too!
Reply 4
franktherabbit
Ok, I've a project to complete in two weeks time. To cut a long rant short, the lecturer has left it until the last minute, didn't show up for one of the most crucial classes and really doesn't seem to be much of a teacher in the long run.

The project:

We have to create a program in Visual Basic for a small business to store information on their products. There should be three buttons on the first form: "product name", "product code" and "stock level".

We need to store the information (apparently) in a table (I have no idea how to visualize this) and the lecturer suggested that we use either string or records (What the frack is a record in VB?!)

As you can see, no amount of reading and research has developed my understanding of VB beyond how to click and drag a pretty button on a form, so any help on this would be greatly appreciated.

Scrap that - I would love you forever. That is, before I go insane.


I think your teacher probably meant as an array. Since I haven't really studied that much on vb I can't be 100% certain. However I would say he wants you to store it in an array and display in list boxes.

The way to store it would be using a counter with an array in a loop.
To add it to a list box use
lstname.additem variable_name
which can also be used in a loop
you could use SQL in VB.NET tis very easy.

Edit: Let me know if you want help with the SQL.
Reply 6
Thanks for the quick response everyone.

It is a college and it's VB6.

Asdalol - Coursework specification is here http://seansstudy.webs.com/computing/part%201%20coursework%20software.doc

It's definetely not a listbox, roar, although I know that because he has shown me a runthrough of his own program (just not the code)

Again as far as I know, it is just a higher/ A level project.

And you're right I need to begin with an array but I'm not sure how to start.
franktherabbit
Thanks for the quick response everyone.

It is a college and it's VB6.

Asdalol - Coursework specification is here http://seansstudy.webs.com/computing/part%201%20coursework%20software.doc

It's definetely not a listbox, roar, although I know that because he has shown me a runthrough of his own program (just not the code)

Again as far as I know, it is just a higher/ A level project.



sorry i can't help you then, if it were VB.NET I could as i've done this for my comp c-w (epos + stock control system)
Reply 8
ask your teacher if you can use VB.net (say you only have the Visual Basic Express 2008 at home), my mate did and his teacher agreed.
Then I would be able to give you a lot of help

freefrag
Reply 9
I don't think you have to do exactly the same as the teacher, I agree that a listbox isn't necessarily the only method that could be used but I think it's the easiest method to display your results.
Thanks for the replies - they set me on the right track and ive managed to set up input boxes for users to input stock info - the only thing is I don't know how to then GET this information to display in a seperate form using labels?
Reply 11
Well this is why i'm suggesting a listbox since you can enter it once in a loop. However you can use this sort of code

formname.labelname=stock_array(1)

and use that 5 times with different variable names if you want to use labels.
Got me on the right track, roar.

However I've used this code:

Private Type ProductType
Product(4) As String
Code(4) As String
Stock(4) As String
End Type 'data type for one record.'

which seems to be causing me confusion as to how the labels will display using the array code you supplied?

(Note: I'm incredibly dimwitted when it comes to programming and must apologise :P)
Reply 13
The stock level array should be integer since u need to do stuff with it in the other subroutines.

Oh and another thing, for some reason, the program doesn't always seem to like it if you don't call arrays, arrays ie my program crashed last time when I tried using code(50). I fixed it by changing it to code_array(50).
Reply 14
Also I've never seen setting variables like that before, for VB6 don't you have to state Dim variable as something?
Reply 15
I just wanted to see the difference between c++ and basic so here is a console app, its not complete (spacing etc etc) but should give you a clear idea. It's not great code and no comments but should be sufficent. Feel free to ask any questions

Public Structure product
Public productName As String
Public productCode As String
Public stock As Integer
End Structure
-------------------------------------------------------------------
Module Module1

-------------------------------------------------------------------
Public Function showStock(ByRef databaseProducts() As product)


Dim counter As Integer = 0
Dim leaveSpace As Integer
Console.WriteLine("Product" & " " & "Product Code" & " Stock")
Do
leaveSpace = 21 - Len(databaseProducts(counter).productName)

Console.Write((databaseProducts(counter).productName))
For counterTwo = 1 To leaveSpace
Console.Write(" ")
Next counterTwo
Console.Write(databaseProducts(counter).productCode & " " & (databaseProducts(counter).stock))
Console.WriteLine()
counter += 1
Loop While databaseProducts(counter).productName <> ""

End Function
-------------------------------------------------------------------
Public Function searchStock(ByRef databaseProducts() As product)
Console.WriteLine("Enter product to be found")
Dim userFind As String = Console.ReadLine
Dim counter As Integer = 0

While 1 = 1

If databaseProducts(counter).productCode = userFind Then
Console.WriteLine((databaseProducts(counter).productName) & " " & databaseProducts(counter).productCode & " " & (databaseProducts(counter).stock))
Exit While

ElseIf databaseProducts(counter).productCode = "" Then
Console.WriteLine("Product not found")
Exit While

End If
counter += 1
End While

End Function
-------------------------------------------------------------------
Public Function purchaseProduct(ByRef databaseProducts() As product)

Dim counter As Integer = 0
Console.WriteLine("Enter product to be bought")


Dim userFind As String = Console.ReadLine
counter = 0
While 1 = 1
If databaseProducts(counter).productCode = userFind Then
If databaseProducts(counter).stock > 0 Then
databaseProducts(counter).stock -= 1
Console.WriteLine("Purchased " & databaseProducts(counter).productName)
Else
Console.WriteLine("sorry out of stock")
End If
Exit While

ElseIf databaseProducts(counter).productCode = "" Then
Console.WriteLine("Product not found")
Exit While

End If
counter += 1
End While
End Function
-------------------------------------------------------------------
Public Function displayLowStock(ByRef databaseProducts() As product)

Dim reStock As String

Dim counter As Integer = 0
Do
If databaseProducts(counter).stock <= 1 Then
reStock = "Re-Order"
Else
reStock = ""

End If
Console.WriteLine((databaseProducts(counter).productName) & " " & databaseProducts(counter).productCode & " " & (databaseProducts(counter).stock) & " " & reStock)
counter += 1
Loop While databaseProducts(counter + 1).productName <> ""

End Function
-------------------------------------------------------------------
Public Function addProductCode(ByRef databaseProducts() As product)

Dim counter As Integer = 0
Do
databaseProducts(counter).productCode = Left(databaseProducts(counter).productName, 3) + Right(databaseProducts(counter).productName, 3)

counter += 1
Loop While databaseProducts(counter).productName <> ""
End Function
-------------------------------------------------------------------
Public Function MainMenu() As Char

Dim userChoice As Char

Console.WriteLine("Main menu")
Console.WriteLine("F)Find product")
Console.WriteLine("P)Purchase Product")
Console.WriteLine("Q)Quit")
Console.Write("Choice: ")
userChoice = Console.ReadLine()
Return userChoice
End Function
-------------------------------------------------------------------
Public Function addProducts(ByRef databaseProducts() As product)

Dim userEntry As String
Dim counter As Integer = 0
Dim userStockEntry As Integer


Do
Console.WriteLine("Please enter name of stock (S to stop)")
userEntry = Console.ReadLine()
If userEntry = "s" Or userEntry = "S" Then
Exit Function
End If

Console.Write("Please enter stock level: ")
userStockEntry = Console.ReadLine()

databaseProducts(counter).productName = userEntry
databaseProducts(counter).stock = userStockEntry
counter += 1

Loop While counter < 9999
End Function
-------------------------------------------------------------------
Sub Main()

Dim databaseProducts(0 To 9999) As product
Dim userChoice As Char


addProducts(databaseProducts)
addProductCode(databaseProducts)
showStock(databaseProducts)

Do
userChoice = MainMenu()

Select Case userChoice
Case "P"
purchaseProduct(databaseProducts)
Case "F"
searchStock(databaseProducts)
Case "Q"
displayLowStock(databaseProducts)
Exit Do
Case Else
Console.WriteLine("Did not understand your entry !")
End Select



Loop While 1 = 1
Console.ReadLine()
End Sub



End Module


franktherabbit


roar558

Reply 16
I wouldn't quite use this method since one of the criteria in the marking requires parameter passing rather than global variables
Reply 17
roar558
I wouldn't quite use this method since one of the criteria in the marking requires parameter passing rather than global variables


There is parameter passing , product is the structure not a parameter. databaseproducts is byRef parameter is being passed on, plus if you want more parameters being passed on byVal you can get user input being passed on at switch. This is the layout taugh at universities (function code would come after main).
Reply 18
Sorry, I'm not very familiar with C++ or many other languages to be honest as I've only really been taught in basic at school, it does look a lot like my code though I've used parameter passing for most of the subroutines.

Latest

Trending

Trending