Click here to Skip to main content
11,494,851 members (50,315 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB.NET
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 18:58pm
Sergey Alexandrovich Kryukov at 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.

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
0 Dnyaneshwar@Pune 692
1 Sergey Alexandrovich Kryukov 350
2 CHill60 318
3 Sascha Lefèvre 280
4 Nakul Chaudhari 236
0 Sergey Alexandrovich Kryukov 10,297
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,864
3 Maciej Los 3,412
4 Richard Deeming 2,500

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2015
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