comp.lang.ada
 help / color / mirror / Atom feed
* Octal Conversion in VB
@ 2003-09-07 15:30 chrissy
  2003-09-07 16:08 ` Ludovic Brenta
  0 siblings, 1 reply; 6+ messages in thread
From: chrissy @ 2003-09-07 15:30 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-09-08  2:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-07 15:30 Octal Conversion in VB chrissy
2003-09-07 16:08 ` 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

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