Could use some tips in VB

11-30-2010, 06:27 AM
Basically I've just started to learn VB a few days ago on my own. I've been doing some exercises and I can't seem to get this one right. I basically have to make 3 textboxes. (Pretty new to whole programming, I just need some pointers to move on.)

1st textbox is for the user to insert a 6 digit number and the second textbox is to take the first number but slowly add it there 1 by 1 (e.g you have 123456 then on second textbox you would have 000000 but then it would tick slowly and reach to 000006 and would stop till you have all the same numbers as on the first textbox. Also, while second textbox is ticking it would affect the 3rd textbox by taking the value for example 000001 (from second textbox) and change it to binary system, which goes to 3rd textbox (also 3rd textbox should always have 20 digits shown).

Visual aid:
1st textbox: 123456
2nd textbox: 000001 (ticking till it reaches to 123456)
3rd textbox: 00000000000000000001 (changes at the same time as 2nd textbox changes)

Any good tips how to make it work?

11-30-2010, 10:01 AM
If you're stuck, it's because you don't quite know how to approach the problem. Programming's more about problem solving than it is about knowing what code to write when, so let's talk about that.

Programming is like giving a person directions. You probably don't have the directions to every landmark in your town memorized, so when you're asked you have to think about how you'd get there and describe it in terms of what you know. Problem solving can boil down to that too. For this problem, we can describe it without talking about text boxes or timers or anything.

You need to get a number. After some event happens, you want to start from 0, add 1, and display the result in both decimal and binary format. This should continue until the result equals the original number.

You could probably implement this in a slow form if I handed you a pencil and paper. Let's talk about it from VB .NET's perspective. The original number will come to you from a text box. This means you'll get a String, but since you need to do math on the number you'll want it as a numeric type like Integer. Integer.TryParse() ( is a good way to do that. Once you have the original number, you need to start another number at 0. That number needs to be increased and displayed at some interval; I'd say the Timer ( component is your best choice for that. The timer lets you specify an interval and it will raise its Tick event each time that interval elapses. You can handle this event and add one to the number and display it. To display it in both decimal and binary formats, you need to convert the number back into a string to get it in a text box. ToString() will work just fine for decimal, but you need something a little bit more fancy for binary. It just so happens there's a version of Convert.ToString() ( that takes a base for conversion; you can use that to get the binary version of the number.

That's a pretty big push in the right direction. If you spend a couple of hours reading the documentation I pointed at and the examples in the documentation you ought to be able to get pretty close.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum