Outputs

Resently I have been working on some calculation software and I have a problem with outputs. What would I replace "MsgBox" with if I wanted the output to go into a text box? (TextBox1.text for example)
And if I wanted both input and the output in the same textbox, what do I do?MsgBox(A - ((B + C) + (D + F) + (G + H)))
[363 byte] By [stargate3216] at [2007-12-16]
# 1
Hi,
What specifically do you mean by outputs and inputs?
As far as I understand your question, you could do this.
(Assuming that your using VB6, bcoz of the msgbox statement)
Dim in_put As Double
Dim out_put As Double

'get input
in_put = CDBL(textBox1.Text)
'do some calculation
out_put = A - ((B + C) + (D + F) + (G + H))
'display both input and output
textBox1.Text = cstr(in_put) & out_put


Note:
Next time, please don't cross-post on other forum groups...
Your post on Visual Basic Language group has already been deleted...
cheers,
Paul June A. Domag
Community Moderator

PaulDomag at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Dear stargate3216

First: It is absolutly your responsibility to choose the appropriate way for outputs, whether is is a messagebox or a textbox.

Second: The first thing I thought about when you said you want the same textbox to be used as input and output is the calculator, built in windows.
Well, you do not have to write extracode to use the input box as the output:
input_var = textbox1.text
'do your calculations
textbox1.text = result_value

I hope this is what you are talking about.
Please let me know if there is more.

You are welcome.

Haitham.ElGhaareeb at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
I tried it didn't work. It said input_var and result_value undefined.
stargate3216 at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4

Ok what code would I use for the + button if the code you gave me was for the = button?

stargate3216 at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5
Hi,
Finally, I quite understand on what you mean. As i understand, your trying to create a calculator (windows style calc) application... So here's a sample routine that I think would get you started...
Dim x as double
dim y as double
'Place this code in your + button
if x = 0 then
x = CDBL(txtInput.Text)
txtInput.Text = "0"
else
y = CDBL(txtInput.Text)
txtInput.Text = x + y
x = y
end if
'Place this code in = button
txtinput.text = x + y
x = 0
well, as you see this code is just good if your doing a + and = operation. If you plan on doing all of the mathematical funcs. THen you should do some major overhauling on the code above. I suggest looking up on MSDN Docs for some help...
cheers,
Paul June A. Domag
PaulDomag at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic General...