BASIC/Visual BASIC Thread

Cromewell

Administrator
Staff member
Please post any questions relating to BASIC/Visual BASIC here. Please also specify which external libraries, if any, you are using.

You can also use this thread to post code you wish to share.
 

FXB

New Member
This is a project.

I have to create a menu from which a customer can order breakfast or lunch.
The customer should be able to enter his name

choose to order from the breakfast or lunch menu

for each menu the customer must be able to select the items which items he wants.
the price for each item must be displayed beside the item.

Once the customer is done ordering he must confirm by pressing a confirmation button

then a new window opens displaying a summary of the order including the customers name the total and the possibility to add a tip. The total price should change according to the tip.

How would I do this?

I use Visual Basic Express edition 2008
 

Cromewell

Administrator
Staff member
What exactly are you looking for? I won't do your homework but I don't mind helping you with certain aspects of it.

In this case, it's a relatively simple project so I'd suggest planning out/designing the initial UI that will be presented then slowly building up the backing code and any other UI objects you need to make it work.

I'm not big on VB2008, the last version I used was 6.
 

Dropkickmurphys

New Member
What exactly are you looking for? I won't do your homework but I don't mind helping you with certain aspects of it.

In this case, it's a relatively simple project so I'd suggest planning out/designing the initial UI that will be presented then slowly building up the backing code and any other UI objects you need to make it work.

I'm not big on VB2008, the last version I used was 6.

There's quite a difference between VB.NET and VB6 I believe. VB.NET is object-oriented, where as VB6 is more procedural I believe?
 

FXB

New Member
Well my first concern is the UI I'm not sure what to make of it.

what would be best?

1. have a window asking for the customer's name and choice of menu. From there open a new window displaying the desired menu Then just do a list and add the prices

or should I do it all in one window? point my in the right direction
 

zombine210

New Member
Hi!
i'm trying to write a script to check free disk space on my file server. so far i have this

On Error Resume Next
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _ &
"(impersonationLevel=impersonate)!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where DriveType = 3")

For Each objItem in colItems

Wscript.Echo objDisk.DeviceID & "=" & Int(objDisk.Size /1048576) & "MB " & FormatPercent(objDisk.FreeSpace / objDisk.Size) * 100) & "% Free"

Next

i know i'm trying to output too much info in one line, but i'm trying to keep it as simple as possible.

i'm getting this error"
>cscript disk.vbs > disk.txt
C:\...\disk.vbs(4, 45) Microsoft VBScript compilation error: Invalid char
acter

i've already rewritten this a few time, still geting the same error
 

zombine210

New Member
ok i deleted the underscore from the third line. i don't get the error anymore.
but now i run the script and there is no output
 

zombine210

New Member
ok, i removed this bit altogether
_ &
"(impersonationLevel=impersonate)!

now i get output, just have to fix it. thanks!
 

S.T.A.R.S.

banned
Well my first concern is the UI I'm not sure what to make of it.

what would be best?

1. have a window asking for the customer's name and choice of menu. From there open a new window displaying the desired menu Then just do a list and add the prices

or should I do it all in one window? point my in the right direction

LoL the look of the program and how the controls will look like and be positioned is totally up to you.Just note that in order to make this work you must know how to perform basic mathematical calculations like + , - , * and / using the integer.The keyword is "int".Or even better you can use the "decimal" in order to work with the decimal numbers and make sure that prices are always completely correctly calculated.

I use the C# 2002 programming language,but the logic is the same.VB is even easier.

Just make sure you know how to perform that and as for the look,keep it as simple as possible because NOT ALL people are smart to use more then one window believe it or not lol.Not all of them are programmers :p
 

S.T.A.R.S.

banned
I wouldn't call myself a programmer I know very little about programming.

Well I am giving instructions to people from C# programming language in order to teach them.I charge 5 dollars per hour.If you want I can teach you the C# programming language either in my appartment or firm if you are here (which is highly unlikely) or online using the Team Viewer software and MSN or Skype.
If you are interested,here is my contact information:

Sellphone number: +385 (0) 918921434
E-mail address: [email protected]

I can show you few things for free,but if you want to really learn,either contact me or buy books and video tutorials.




Cheers!
 

FXB

New Member
Well I am giving instructions to people from C# programming language in order to teach them.I charge 5 dollars per hour.If you want I can teach you the C# programming language either in my appartment or firm if you are here (which is highly unlikely) or online using the Team Viewer software and MSN or Skype.
If you are interested,here is my contact information:

Sellphone number: +385 (0) 918921434
E-mail address: [email protected]

I can show you few things for free,but if you want to really learn,either contact me or buy books and video tutorials.
Thanks I'll consider it.


Here is what I've done for the UI so far.
Caf%25C3%25A9+jean.PNG


Advice or feedback?

How would I get this window to disappear and display the menu?
 

tlarkin

VIP Member
Hi!
i'm trying to write a script to check free disk space on my file server. so far i have this



i know i'm trying to output too much info in one line, but i'm trying to keep it as simple as possible.

i'm getting this error"


i've already rewritten this a few time, still geting the same error

Not to derail this thread, but man you should check out python. There are modules built in (like millions of them) that you can call functions in scripts to do all sorts of OS level stuff, like checking and reporting free disk space.

Python also runs on every single platform, so if you write it for Windows it will still work on Linux and Mac OS X, with the exception of any actual system commands from that OS you may have to change.
 

Troncoso

VIP Member
Well I am giving instructions to people from C# programming language in order to teach them.I charge 5 dollars per hour.If you want I can teach you the C# programming language either in my appartment or firm if you are here (which is highly unlikely) or online using the Team Viewer software and MSN or Skype.
If you are interested,here is my contact information:

Sellphone number: +385 (0) 918921434
E-mail address: [email protected]

I can show you few things for free,but if you want to really learn,either contact me or buy books and video tutorials.


Cheers!

No lie, giving out your phone number on a public forum is not a good idea. Really neither is e-mail.
 

Troncoso

VIP Member
Thanks I'll consider it.


Here is what I've done for the UI so far.
Caf%25C3%25A9+jean.PNG


Advice or feedback?

How would I get this window to disappear and display the menu?


Is that the main form? If so, I believe it would be easier if you created 2 forms on top of the main one that display when the program runs. The first will be this screen, the second will be the menu. Then it'll move to your main form. Just an idea.

As for changing forms. I've not used basic since high school. I couldn't tell you exactly. Just google 'switching forms, vb.net'
 

Cromewell

Administrator
Staff member
Well my first concern is the UI I'm not sure what to make of it.

what would be best?

1. have a window asking for the customer's name and choice of menu. From there open a new window displaying the desired menu Then just do a list and add the prices

or should I do it all in one window? point my in the right direction

Is that the main form? If so, I believe it would be easier if you created 2 forms on top of the main one that display when the program runs. The first will be this screen, the second will be the menu. Then it'll move to your main form. Just an idea.

As for changing forms. I've not used basic since high school. I couldn't tell you exactly. Just google 'switching forms, vb.net'

Agreed, using the main form to hold the user name and let them select dinner or lunch is good. Then when they pick their menu you can open it and let them pick what they want. Yuo could even use 3-4 forms if you wanted: a main screen, a lunch menu, dinner menu and then an invoice form. As for hiding the form and displaying the next it's likely similar to vb6 ( ie: formname.hide()/formname.show() ). The actual way of selecting the form may be slightly differrent than that though, I'm finding a lot of people who are writing what looks like vb6 code in their 2008 VB.NET apps so it's hard to tell the difference.
 

S.T.A.R.S.

banned
Thanks I'll consider it.


Here is what I've done for the UI so far.
Caf%25C3%25A9+jean.PNG


Advice or feedback?

How would I get this window to disappear and display the menu?

Please translate that language to english on that picture lol.I am lost xD

Anyway it would be good that on the first form you give the users to simply just choose what they want.If for example they want dinner,just make that after the DINNER button (or any other control you want) is clicked (or whatever event you want to use) that the SECOND FORM for the DINNER and ONLY DINNER is showed and that the user can choose what he/she wants for the dinner from the list of all meals you are offering to them.As for the meals menu,I would recommend using the LIST BOX control or at least the COMBO BOX control.

Tip 1: To add another form to your project,go to the solution explorer,right click your project name and choose ADD ITEMS and from the windows that will open choose Form2.vb (or however it is called in VB 2008 .NET).

Tip 2: Here is the code how to close,dispose,show and hide the form:

CLOSE---> me.Close()
DISPOSE---> me.Dispose(true)
SHOW---> Form2.Show()
HIDE---> Form2.Hide()

Here is the C# version for the SHOW and HIDE:

SHOW:

Form2 blabla=new Form2();
blabla.Show();

HIDE:

Form2 blabla=new Form2();
blabla.Hide();

Tip 3: You may want to show the form to the user as the modal dialog box.That means that the user wont be able to use the previous window in the program as long as the current window is opened.That can sometimes be useful so that the user doesnt do dozens of things on the previous windows accidentaly.Here is how to do that in the Visual Basic:

Form2.ShowDialog()

Tip 4: As for closing the forms,I would rather use "Me.Dispose(true)" because that will close the form and also remove ALL ITS usage from the memory.For the difference of CLOSE which just closes the form window,but does NOT remove it from the memory completely.




Cheers!
 

FXB

New Member
So heres what I've done.

The main window asks for the users name

then ask which menu he wants either Breakfast or lunch
Caf%25C3%25A9+jean.PNG

then if the user clicks on the breakfast button I have a form for the breakfast menu that will appear.
Jean+Caf%25C3%25A9+dej.PNG


If the user select the lunch menu I have a dedicated form for that as well
Cafe+Jean+Diner2.PNG


As you mentioned the CheckedList Box seems more pratical is there an easy way to switch between the two?


I started writing the code and I can't figure out what these errors are HELP!
CAfeJean+code+1.PNG
 
Last edited:

Troncoso

VIP Member
Please translate that language to english on that picture lol.I am lost xD

Anyway it would be good that on the first form you give the users to simply just choose what they want.If for example they want dinner,just make that after the DINNER button (or any other control you want) is clicked (or whatever event you want to use) that the SECOND FORM for the DINNER and ONLY DINNER is showed and that the user can choose what he/she wants for the dinner from the list of all meals you are offering to them.As for the meals menu,I would recommend using the LIST BOX control or at least the COMBO BOX control.

Tip 1: To add another form to your project,go to the solution explorer,right click your project name and choose ADD ITEMS and from the windows that will open choose Form2.vb (or however it is called in VB 2008 .NET).

Tip 2: Here is the code how to close,dispose,show and hide the form:

CLOSE---> me.Close()
DISPOSE---> me.Dispose(true)
SHOW---> Form2.Show()
HIDE---> Form2.Hide()

Here is the C# version for the SHOW and HIDE:

SHOW:

Form2 blabla=new Form2();
blabla.Show();

HIDE:

Form2 blabla=new Form2();
blabla.Hide();

Tip 3: You may want to show the form to the user as the modal dialog box.That means that the user wont be able to use the previous window in the program as long as the current window is opened.That can sometimes be useful so that the user doesnt do dozens of things on the previous windows accidentaly.Here is how to do that in the Visual Basic:

Form2.ShowDialog()

Tip 4: As for closing the forms,I would rather use "Me.Dispose(true)" because that will close the form and also remove ALL ITS usage from the memory.For the difference of CLOSE which just closes the form window,but does NOT remove it from the memory completely.




Cheers!

To avoid confusion of these language threads can you please keep C# in it's own place.
 

Cromewell

Administrator
Staff member
For your first error, the compiler is saying it doesn't know how to turn a string into a label. You are missing the property you want to set (in this case I believe it is .text)
Code:
You have:
LblSaisieNom = txtSaisieNom.Text
You want:
LblSaisieNom.Text = txtSaisieNom.Text
The second error tells you what you need to do ;)
Code:
You have:
frmCafeJean.Hide()
You want:
Me.Hide()
 
Top