Newly a Beginner Programming Student

jamescv7

Level 85
Thread author
Verified
Honorary Member
Forum Veteran
Mar 15, 2011
13,070
17,982
8,379
29
Philippines
Hi everyone :), well I came here for a help since even though its a basic calculator program on Visual Basic 6 (which our standard program), my problem is how to figure it on source code itself.

I know everything is in the internet (Source Code itself) but basically this picture that we've made would be the base and our teacher managed to worked for it.

dpd53m.png


I know how to make it if its our own version of calculator but since this picture shown above was our standard form.

The name property were as follows:

Labels: lblsign (top) and lblanswer (below)
Text boxes: txtfirst and txtsecond
Commands: cmdadd, cmdsub, cmdmul, cmddiv.

We are allowed to conduct a research to found the source code and of course I'm wiliing to learn.

Actually our activity will be held on saturday but we can practice it in our home. :)

P.S: Sorry I'm really a newbie for it since a first time for me. :lol:
 
I am having trouble in what your asking, are you looking for the code? It has been many years since I used MS vbasic but if its a .vbs file you can open it with notepad (this is a better version http://notepad-plus-plus.org/download/v6.1.4.html)
 
Hi pcjunklist :), basically a code for that the picture showed and to make it work as a calculator.

There are lots of source code but different style of calculator.

So I want to know if what is the code to make this calculator work on the picture above.
 
Its been a while since i have done any vb.net. But all you will have to do is in the the click event handler for each button put somehting liek this (Syntax may not be perfect).

you want to dimension the text from the text box and the answer.

dim digit_one as integer
dim digit_two as integer
dim ans as integer

digit_one = txtone.text
digit_two - txttwo.text

### CMDAdd click event handler (double click the button to create this) ###

ans = digit_one + digit_two
(or could be something like int(digit_one+digit_two) cant remember exact syntax)
lblanswer.text = ans

### end of event handler ####

Then do the smame for each button with the different arithmetic operator.
 
Try to do it on your own and I am sure it will be very interesting. Atleast that's how it was when I learnt it. Offcourse if you want we are here to guide you.

Once you click on any command button (arithmetic operators) first of all you need to select and store the numbers from each text boxes.

num1 = val (txtfirst.text)
num2= val ( txtsecond.text)

Then just perform the operation on those 2 numbers and display it on the label box.
Make sure to clear the text boxes as well.

txtfirst.text= ""
txtsecond.text= ""

Basically all the events will occur on your cmd buttons click.

Private Sub cmdadd_Click()

Dim num1,num2,num3 As Integer
num1 = val (txtfirst.text)
num2= val ( txtsecond.text)
num3= num1 + num2
lblanswer.text = num3
txtfirst.text= ""
txtsecond.text= ""
End Sub

Repeat this code for the other three operators (make sure to change the operations on num1 and num2) and you are done.
 
You may as well ignore my example amazingAG's is much better and more likely to work. I only write code in python and the Linux shell BASH these days.
 
Oh well never mind :lol: managed to figured out so I think just to explore first from the codes of visual basic before asked on it.
 
Do come back if you have more queries or questions. :D