[Gambas-user] binary numeral system

Emil Tchekov emil at ...1913...
Tue Apr 14 12:59:43 CEST 2009


Hi,

I do not have so much experience with Gambas, but a lot with VB


What I will do in such case:

Write a subroutine that gets string as input and converts it in a decimal
number.

Than create your control (text box) and bind the change event (AfterUpdate
in VB) with your routine...

That is all.

On each character tipped in the box the subroutine is invoked and new result
will be produced.

Ofcourse you have to add some error handling (as Example: catch any other
chars different from 0 and 1, avoid overflow trough accepting only defined
number of chars etc.)

Hope this helps


kind regards

Emil





-----Ursprungliche Nachricht-----
Von: vlahonick vlahonick [mailto:tsopanotragi at ...67...]
Gesendet: Dienstag, 14. April 2009 11:22
An: gambas-user at lists.sourceforge.net
Betreff: [Gambas-user] binary numeral system



hello all :D

i am trying to create a program that calculates a number from the binary
numeral system and gives a result

example of what the program will do :

we have the number (at binary numeral system) 10011

so to have result we have to do (1*2^4)+(0*2^3)+(0*2^2)+(1*2^1)+(1*2^0)=
16+0+0+2+1=19

to do that in a program first i have to calculate the powers
so i have to write (y=number of digits) for the first of the digits
y-1,second y-2etc

so if i have 5 digits then the power for the first one will be y-1=5-1=4

this is done by the Len(textbox1.text)

but HOW i will write Len(textbox1.text)=y ?????

then how i can make the program to recognize that for the 1st digit entered
in the Textbox1.text have to
give (d*2^y-1) (d=the digit that can be 0 or 1 and y the number of the
digits) for the second (d*2^y-2)etc...

so the main question is how i can make JUST ONE TEXTBOX to understand that
for every digits enter it will give something else for a result

sorry about my english but it has been long time since i had english
lessons...
plz if u dont understand something let me know and i will try to explain
better...
if you want to contact me directly :tsopanotragi at ...67... |
vlahonick at ...626... | chris at ...2135...

thanks in advance Vlahonick (all the truth is always in
www.vlahonick.freehost.gr)

_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
----------------------------------------------------------------------------
--
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user





More information about the User mailing list