1 Replies - 2010 Views - Last Post: 10 April 2008 - 02:38 PM Rate Topic: -----

#1 powellm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 30-March 08

Overflow error

Posted 10 April 2008 - 02:09 PM

Private Sub cmdCount_Click()
    Dim strText As String
    Dim strLetter As String
    Dim intNumOccurences As Integer
    Dim intSearchPos As Integer
    Dim intLetterPos As Integer
    
    strText = txtText.Text
    strLetter = txtLetter.Text
    intNumOccurences = 0
    intSearchPos = 1
    
    Do
        intLetterPos = InStr(1, strText, strLetter)
        If intLetterPos > 0 Then
            [b]intNumOccurences = intNumOccurences + 1            Error occurs with this line [/b]
            intSearchPos = intLetterPos + 1
        End If
    Loop While intSearchPos <= Len(strText) And intLetterPos <> 0
        
        lblTimes.Caption = intNumOccurences
        
        
End Sub


*edit: Please use code tags in the future, thanks! :code:


How do i fix the line to prevent an over flow error?

This post has been edited by Martyr2: 10 April 2008 - 02:39 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Overflow error

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4313
  • View blog
  • Posts: 12,090
  • Joined: 18-April 07

Re: Overflow error

Posted 10 April 2008 - 02:38 PM

An overflow error is when you run over the bounds of what a data type can hold. So to fix your problem you either need to increase the size of your data type (like to a "long") or change your design a little.

But in order to have overloaded this variable you must be chewing through quite a bit of text. Going with a long should be big enough for you to hold the value you need.

See if that works for you. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1