comp.lang.ada
 help / color / mirror / Atom feed
From: chrissy_brady1@yahoo.com (chrissy)
Subject: Octal Conversion in VB
Date: 7 Sep 2003 08:30:39 -0700
Date: 2003-09-07T15:30:41+00:00	[thread overview]
Message-ID: <f8f1b420.0309070730.e42c6dd@posting.google.com> (raw)

I was playing around in VB trying to come up with a simple application
to convert entered strings of alphanumerics into octal numbers.

I took the approach of declaring a series of variables as integers,
and calling the library functions "Val" and "Str" to handle the data
conversions from the text box I was using to key in the alphanumerics
and to the text box I was assigning the resulting string.

I then wrote a series of expressions to assign values to each of the
declared variables, in sequence.

I then concatenated the resultant character string to produce the
number sequence.

Thus:  

Private Sub cmdConvert_Click()

Dim A, B, C, D as Integer

A = Val(txtDecimal.Text)
B = A Mod 8
C = A \ 8 Mod 8
D = A \ (8 ^ 2) 
txtOctal.Text  = Str(D) + Str (C) + Str (B)  

End Sub

This seemed to work, but the code looked ugly, and I'm not sure a
truth table would support the conversion to infinity. Am I right?

Is there a better and tidier way?


Hoping for some guidance


Chrissy



             reply	other threads:[~2003-09-07 15:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-07 15:30 chrissy [this message]
2003-09-07 16:08 ` Octal Conversion in VB Ludovic Brenta
2003-09-07 20:14   ` Robert I. Eachus
2003-09-07 20:22     ` David C. Hoos
2003-09-07 23:07       ` Robert I. Eachus
2003-09-08  2:46     ` chrissy
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox