Code added to 'Community content' to give a similar result to the 'Power' function given in the Visu

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi ALL,
I looked at the C# example here and Ive just posted VB.Net code that produces a similar result here:>>
<span style="text-decoration:underline http://msdn.microsoft.com/en-us/library/9k7k7cf0(v=VS.90).aspx#Y379 http://msdn.microsoft.com/en-us/library/9k7k7cf0(v=VS.90).aspx#Y379

In case some of you find it useful here it is again with the usual syntax colouring. :-)
>>

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Option Strict <span style="color:Blue; On
<span style="color:Blue; Option <span style="color:Blue; Explicit <span style="color:Blue; On
<span style="color:Blue; Option Infer <span style="color:Blue; Off

<span style="color:Blue; Public <span style="color:Blue; Class Form1

<span style="color:Blue; Private <span style="color:Blue; Sub Button1_Click(<span style="color:Blue; ByVal sender <span style="color:Blue; As System.Object, <span style="color:Blue; ByVal e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles Button1.Click

<span style="color:Blue; Dim results <span style="color:Blue; As System.Collections.Generic.IEnumerable(Of <span style="color:Blue; Integer)
results = Power(2, 8)

<span style="color:Blue; Dim sb <span style="color:Blue; As <span style="color:Blue; New System.Text.StringBuilder
<span style="color:Blue; For <span style="color:Blue; Each num <span style="color:Blue; As <span style="color:Blue; Integer <span style="color:Blue; In results
sb.Append(num.ToString & <span style="color:#A31515; " ")
<span style="color:Blue; Next

MessageBox.Show(sb.ToString)

<span style="color:Blue; End <span style="color:Blue; Sub

<span style="color:Blue; Public <span style="color:Blue; Function Power(<span style="color:Blue; ByVal number <span style="color:Blue; As <span style="color:Blue; Integer, <span style="color:Blue; ByVal exponent <span style="color:Blue; As <span style="color:Blue; Integer) <span style="color:Blue; As System.Collections.Generic.IEnumerable(Of <span style="color:Blue; Integer)

<span style="color:Blue; Dim result <span style="color:Blue; As <span style="color:Blue; New List(Of <span style="color:Blue; Integer)

<span style="color:Blue; For index <span style="color:Blue; As <span style="color:Blue; Integer = 1 <span style="color:Blue; To exponent
result.Add(Convert.ToInt32(Math.Pow(number, index)))
<span style="color:Blue; Next
<span style="color:Blue; Return result.AsEnumerable

<span style="color:Blue; End <span style="color:Blue; Function

<span style="color:Blue; End <span style="color:Blue; Class
[/code]
<br/>
<br/>
<hr class="sig <
<h5>Regards,<br/>
<br/>
http://stackoverflow.com/users/895788/john-anthony-oliver <img src="http://stackoverflow.com/users/flair/895788.png" width="208" height="58" alt="profile for John Anthony Oliver at Stack Overflow, Q&A for professional and enthusiast programmers" title="profile for John Anthony Oliver at Stack Overflow, Q&A for professional and enthusiast programmers
</h5>
<
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/b15c28f5-1f7a-4053-97fc-2ece42e2f58d" target="blank Click this link to see the NEW way of how to insert a picture into a forum post.
<br/>
<br/>
http://www.fortypoundhead.com/showcontent.asp?artid=20502" target="blank Installing VB6 on Windows 7
<br/>
<br/>
http://create.msdn.com/en-us/home/getting_started" target="blank App Hub for Windows Phone & XBOX 360 developers.
<

View the full article
 
Back
Top