| View previous topic :: View next topic |
| Author |
Message |
xXx123 Expert Cheater
Reputation: 0
Joined: 27 Sep 2007 Posts: 118
|
Posted: Wed Nov 14, 2007 5:15 pm Post subject: can you do programs in vb6? |
|
|
i dont mean very good ones but simple ones... like i dont know like a calculator... can u give me more exaamples and how to do it?
thank you
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Wed Nov 14, 2007 5:42 pm Post subject: |
|
|
Something very basic:
Add 1 command button to your form. Use the code:
| Code: | Private Sub Command1_Click()
MsgBox "1 + 1 = " & Val(1 + 1)
End Sub |
To make it a little more advanced, add two text boxes to your form and use:
| Code: | Private Sub Command1_Click()
MsgBox Text1.Text & " + " & Text2.Text & " = " & (Val(Text1.Text) + Val(Text2.Text))
End Sub |
Use your common sense from there to add other things and so on.
_________________
- Retired. |
|
| Back to top |
|
 |
xXx123 Expert Cheater
Reputation: 0
Joined: 27 Sep 2007 Posts: 118
|
Posted: Wed Nov 14, 2007 5:48 pm Post subject: |
|
|
| thank you but can you give more examples...
|
|
| Back to top |
|
 |
XxOsirisxX Grandmaster Cheater Supreme
Reputation: 0
Joined: 30 Oct 2006 Posts: 1597
|
Posted: Wed Nov 14, 2007 9:08 pm Post subject: |
|
|
+ = Add
- = substract
* = multiplication
/ = division
Make a new project, with 2 textbox, 1 label and 4 buttons..
in the first command (add) add this..
| Code: | | Label1.caption = val(text1) + val(text2) |
Add the same line for the others buttons, but remplace the "+" for the other operator ( - , * , / ).
There you got a cheap calculator on VB.
_________________
|
|
| Back to top |
|
 |
MisterT Advanced Cheater
Reputation: 0
Joined: 30 Aug 2006 Posts: 76
|
Posted: Wed Nov 14, 2007 11:02 pm Post subject: |
|
|
Sadly yeah, though I don't recommend as an introduction to programming, Try some other less-visual oriented programs...
As the previous post have stated,
Declare a variable as double, integer or any other type you want and create two textboxes, a button and a label/textbox or use a msgbox, (but of course msgboxes are annoying).
declare (dim) variable as integer/variant/double/etc
Private Sub Command1_Click()
variable = textbox 1 + textbox 2
label1.caption =variable
End Sub
_________________
Finished on 10/21/06, 17:31, by MisterT |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
|
| Back to top |
|
 |
|