1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

"Invalid use of Property"

Discussion in 'Visual Basic ( VB )' started by Donarco, Jun 9, 2012.

  1. Donarco

    Donarco New Member

    Joined:
    Sep 12, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Writing Computer Programs
    Location:
    Morris Oklahoma
    Thread Title: "Invalid Use of Property"

    I'm having difficulty with a very small routine and am listing code below:
    Code:
      
      Dim OBplus As Double
      Dim sOBplus As String
      Dim OBNonPlus As Double
      Dim sOBNonPlus As String
      
      ' Accumulates to Variables OBPlus & OBNeg
      rsGlact.MoveFirst
      Do While rsGlact.EOF = False
        gAcno = rsGlact.Fields("Acno")
        If rsGlact.Fields("Rptype") = "P" Then
          If rsGlact.Fields("Oldbal") > 0 Then
            OBplus = (OBplus + rsGlact.Fields("Oldbal"))
          Else
            OBNeg = (OBNeg + rsGlact.Fields("Oldbal"))
          End If
        End If
        rsGlact.MoveNext
      Loop
      
      ' Determines Difference and stores Round()
      txtOBPlus = OBplus
      txtOBNeg = OBNeg
      txtDiffOld = (OBplus + OBNeg)
      txtDiffOld = Round(txtDiffOld, 2)
      
      Dim OBplus As Double
      Dim sOBplus As String
      Dim OBNeg As Double
      Dim sOBNeg As String
      
      rsGlact.MoveFirst
      Do While rsGlact.EOF = False
        gAcno = rsGlact.Fields("Acno")
        If rsGlact.Fields("Rptype") = "P" Then
          If rsGlact.Fields("Oldbal") > 0 Then
            OBplus = (OBplus + rsGlact.Fields("Oldbal"))
          Else
            OBNonPlus = (OBNonPlus + rsGlact.Fields("Oldbal"))
          End If
        End If
        rsGlact.MoveNext
      Loop
      
      ' Determines Difference and stores Round()
      txtOBPlus = OBplus
      txtOBNonPlus = OBNonPlus
      txtDiffOld = (OBplus + OBNonPlus)
      txtDiffOld = Round(txtDiffOld, 2)
        
      sOBplus = OBplus
      sOBNeg = OBNeg
     
      txtOBPlus = sOBplus
      txtOBNeg = sOBNeg
      
    It's at this point that my problem occurs. When attempting to enter to frmUtility, I receive the following error: "Invald use of Property"

    I will greatly appreciate help.

    Don Gaither
     
    Last edited by a moderator: Jun 10, 2012
  2. Donarco

    Donarco New Member

    Joined:
    Sep 12, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Writing Computer Programs
    Location:
    Morris Oklahoma
    This is a correction of an earlier Post:

    I'm having difficulty with a small routine, the code for which I'm listing below:
    Code:
     
      Dim OBplus As Double
      Dim sOBplus As String
      Dim OBNonPlus As Double
      Dim sOBNonPlus As String
      
      rsGlact.MoveFirst
      Do While rsGlact.EOF = False
        gAcno = rsGlact.Fields("Acno")
        If rsGlact.Fields("Rptype") = "P" Then
          If rsGlact.Fields("Oldbal") > 0 Then
            OBplus = (OBplus + rsGlact.Fields("Oldbal"))
          Else
            OBNonPlus = (OBNonPlus + rsGlact.Fields("Oldbal"))
          End If
        End If
        rsGlact.MoveNext
      Loop
      
      ' Determines Difference and stores Round()
      txtOBPlus = OBplus
      txtOBNonPlus = OBNonPlus
      txtDiffOld = (OBplus + OBNonPlus)
      txtDiffOld = Round(txtDiffOld, 2)
      
      
      sOBplus = OBplus
      sOBNeg = OBNeg
     
      txtOBPlus = sOBplus
      txtOBNonPlus = sOBNeg
    
    Its at this point that the error ("Invalid use of Preperty") occurs. I have written numerous similar routines with no problem.

    I will greatly appreciate help in solving this problem.

    DONARCO
     
    Last edited by a moderator: Jun 10, 2012
  3. jailbot

    jailbot New Member

    Joined:
    Jun 10, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0

    plz tell me where did you assign a value to OBneg????
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    I have merged your threads. For correction, you don't need a second thread.
     
  5. pein87

    pein87 New Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    0
    Occupation:
    Web Dev
    Location:
    Limbo
    You have undeclared variables that your trying to assign values to. Check the last chunk of code so see where you dimensioned those variables.

    Code:
    sOBNeg = OBNeg
    
    txtOBPlus = sOBplus
    txtOBNonPlus = sOBNeg
    Your trying to use the MoveFirst property when I don't see where you gave reGlact an instance of a class. Do you use visual studio or visual basic express?
     
  6. Donarco

    Donarco New Member

    Joined:
    Sep 12, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Writing Computer Programs
    Location:
    Morris Oklahoma
    To Those Respondants:

    I have used excerpts from multiple responses and my routine is now working just fine. Thanks very
    much for your time and trouble.

    donarco (Don Gaither)
     

Share This Page