Click here to Skip to main content
12,997,531 members (58,928 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Dim s, temp As String
Dim a, b, c As Long

a = CLng(Val(TxtBoxInput.Text))
s = TxtBoxInput.Text
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

Posted 18-Apr-13 17:58pm
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.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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


input 123

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

= 1 + 4 + 3
= 8

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100