First off, that is some odd code you have there:
for (int i = textBox1.TextLength - 1; i < textBox2.TextLength - 1; i++)
{ num1 = "0" + textBox1.Text; }
What does that do?
It's the same as:
Since the code inside the loop doesn't use the loop variable
i
, or change anythign other than the
num1
value, it's the same as not having a loop at all - it just loads teh same value into
num1
several times...
I can see what you are trying to do, sort of - but assuming that each character in num1 is zero or one (or it isn't binary) how can the result ever be three?
0 + 0 == 0
0 + 1 == 1
1 + 0 == 1
1 + 1 == 2
So the testing in your main processing loop is...um...odd.
I'd sort that out before you try to get to multiplication! :laugh:
[edit]Ignore that: I forgot the carry! :O [/edit]
So, the inner loop will work - so multiplication is pretty easy:
Think how you were taught to do multiplication:
7 * 5 == 7 + 7 + 7 + 7 + 7
Then for more advanced users there is long mutiplication:
123
*45
---
4920
+615
----
5535