4 Replies - 570 Views - Last Post: 26 April 2009 - 04:24 AM Rate Topic: -----

#1 Flying Pig  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-April 09

Question on remembering results

Post icon  Posted 26 April 2009 - 02:28 AM

This is probably a stupid question, but how do you make a function which takes a number then does an operation to it again and again until it gets a vlue which it already has seen, when it returns all of its values? I have this function:


Private Function fractal(d as string) As double

Fractal = Val(D) * (Val(D) - 1)
Fractal = FormatNumber (Fractal, 2)
Return Fractal




Is This A Good Question/Topic? 0
  • +

Replies To: Question on remembering results

#2 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Re: Question on remembering results

Posted 26 April 2009 - 03:52 AM

its a good Idea but I would start using a listbox and adding every result to this list box and if a result matches one in the listbox then you will get a message box or whatever you want -

Fractal = Val(D) * (Val(D) - 1)
Fractal = FormatNumber (Fractal, 2)
Return Fractal
listbox1.Items.Add(Fractal)

' this is something i just snabbed of the code prject site (but i bet you could get it to work for you it adds a found result into another listbox:'
 Dim listLength As Integer = (ListBox1.Items.Count - 1)

'//i -> counter through loops : j -> counter through chars in string

Dim i, j As Integer

'//listString -> string of item in ListBox1

'//newString -> gets added to one char at a time from listString

Dim listString, newString As String

'//self explanitory, lol

If radioFull.Checked = True Then

'//loop through all items in ListBox1

For i = 0 To listLength

'//one at a time in sequential order

listString = ListBox1.Items.Item(i)

'//searches ListBox1 Item for the text in TextBox1

'//turning all text to lowercase

If InStr(listString.ToLower, TextBox1.Text.ToLower) Then

'//if text is found then add ListBox1 Item to ListBox2

ListBox2.Items.Add(listString)

End If




Code: http://www.codeproje...tboxsearch.aspx
Was This Post Helpful? 0
  • +
  • -

#3 Aurel300  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 230
  • Joined: 10-November 07

Re: Question on remembering results

Posted 26 April 2009 - 04:21 AM

Or, if you donīt want to make this with list box and stuff, just use a loop.
Private Function fractal(d as string) As double
fractalNumbers = New ArrayList
Dim seenNumber As Boolean = False
While (seenNumber = False)
Dim cFractal As Double
cFractal = Val(D) * (Val(D) - 1)
cFractal = FormatNumber (cFractal, 2)
Dim numberCount As Integer = 0
While (numberCount < fractalNumbers.Count())
If (fractalNumbers(numberCount) = cFractal) Then
seenNumber = True
End If
numberCount += 1
End While
End While
Return fractalNumbers ' As an ArrayList, very similar to Array. Just something(index) and you have value of that member. And, just for this thing, I added the fractalNumbers as a remebered member, so that you can access it anytime.
End Function
Private fractalNumbers As New ArrayList


This post has been edited by Aurel300: 26 April 2009 - 04:22 AM

Was This Post Helpful? 0
  • +
  • -

#4 Flying Pig  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-April 09

Re: Question on remembering results

Posted 26 April 2009 - 04:22 AM

Thanks a lot - where does all of this go? In the same place as my function?

EDIT: Cross-post

This post has been edited by Flying Pig: 26 April 2009 - 04:23 AM

Was This Post Helpful? 0
  • +
  • -

#5 Aurel300  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 230
  • Joined: 10-November 07

Re: Question on remembering results

Posted 26 April 2009 - 04:24 AM

View PostFlying Pig, on 26 Apr, 2009 - 03:22 AM, said:

Thanks a lot - where does all of this go? In the same place as my function?

EDIT: Cross-post


Yes, just replace your old function with this.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1