Click here to Skip to main content
Rate this: bad
good
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
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 18-Apr-13 18:58pm
Comments
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.
—SA

1 solution

Rate this: bad
good
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
 
e.g
 
input 123
 
output ...
1 ^ 3 + 2 ^ 2 + 3 ^ 1
 
= 1 + 4 + 3
= 8
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 120
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


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