Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dim s, temp As String
Dim a, b, c As Long

a = CLng(Val(TxtBoxInput.Text))
s = TxtBoxInput.Text
TxtBoxInput.Clear()
For i = 1 To Len(s) Step 1
b = CLng(Mid(s, i, 1))
c = Len(s) - i
b = CLng(Val(b) * (2 ^ c))
temp = CStr(Val(temp) + b)
Next i

MessageBox.Show(temp)
Posted
Comments
Sergey Alexandrovich Kryukov 19-Apr-13 0:29am    
Wrong approach to learning anything. Do you understand that the notion "explain" is not something defined? Without knowing of your background, it could range from a whole book starting from explaination what a variable means (declaration, initialization, type...) to just few words.

Also, imagine if everyone will try to pull every stupid piece of code from the Web and ask for explanation. The code should be explained only by its author. And you can ask only on the code you are trying to write.

So, please don't ask such questions. They make no sense.
—SA

1 solution

Set up some variables
make a = a number = whatever was typed into the text box
make s = the text from the text box
clear the text box
for each character in the text box
set b = that character
set c = the length of the original string less the position within the string that we're looking
calculate b = b ^ c (i.e. b to the power of c)
concatenate b to the end of temp

So it takes a number, and for each digit calculates its value to the power of its position from teh right of the number, and wriutes that out as a new number

e.g

input 123

output ...
1 ^ 3 + 2 ^ 2 + 3 ^ 1

= 1 + 4 + 3
= 8
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900