# Question on remembering results

Page 1 of 1

## 4 Replies - 768 Views - Last Post: 26 April 2009 - 04:24 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=101671&amp;s=66537a4ea7c8d822b339908e369f6c57&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Flying Pig

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

# Question on remembering results

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

Reputation: 35
• 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

' 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

'//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

End If

```

Code: http://www.codeproje...tboxsearch.aspx

### #3 Aurel300

Reputation: 13
• 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

### #4 Flying Pig

Reputation: 0
• 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

### #5 Aurel300

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

## Re: Question on remembering results

Posted 26 April 2009 - 04:24 AM

Flying 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.