943,973 Members | Top Members by Rank

Ad:
Sep 12th, 2007
0

vb6 - RunTime error 1004 Invalid number of arguments

Expand Post »
Hello everybody,
my program have been working and today I'm getting run time error 1004 - invalid number of arguments on this line of code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. mystr = "Comments:" & "'" & xlApp.Clean(Trim(rsin![Comments]))

Also, I am getting a "Runtime error 1004 - unable to set the RowHeight Property of the range class" on this code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. RowHeight = .Font.Size * (Len(xlWksht.Range("A" & ii + 1).text) - Len("Comments:")) / w + rht + (rht - .Font.Size) + newlinecnt * .Font.Size

Can anyone tell me what went wrong?

Below is my entire procedure:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ii = 5
  2. w = 0
  3. For Each R In xlWksht.Range("A8:h8"): w = w + R.ColumnWidth: Next
  4.  
  5. rht = xlWksht.Range("A6").RowHeight
  6.  
  7. Do Until rsin.EOF = True
  8. ii = ii + 2
  9. xlWksht.Cells(ii, 1).Value = rsin![Req No]
  10. xlWksht.Cells(ii, 2).Value = rsin![Description]
  11. xlWksht.Cells(ii, 3).Value = rsin![P L] & Chr(10) & rsin![Pgmr2] & Chr(10) & rsin![Pgmr3]
  12. xlWksht.Cells(ii, 4).Value = rsin![ClientName] & Chr(10) & rsin![Status]
  13. xlWksht.Cells(ii, 5).Value = "-" & Chr(10) & rsin![Per Hrs]
  14. xlWksht.Cells(ii, 6).Value = rsin![Hours] & Chr(10) & rsin![Tot Hrs]
  15. xlWksht.Cells(ii, 7).Value = rsin![Start Date] & Chr(10) & rsin![Start Date]
  16. xlWksht.Cells(ii, 8).Value = rsin![End Date] & Chr(10) & rsin![End Date]
  17. 'xlWksht.Cells(ii + 1, 1).Value = "Comments:" & Chr(10) & "'" & xlApp.Clean(Trim(rsin![Comments]))
  18.  
  19. mystr = "Comments:" & "'" & xlApp.Clean(Trim(rsin![Comments]))
  20. Do
  21. Pos = InStr(Pos + 1, mystr, ":")
  22. If Not Pos = 0 Then
  23. If Mid(mystr, Pos - 5, 1) = "/" Then
  24. mystr = Left(mystr, Pos - 11) & Chr(10) & Mid(mystr, Pos - 10, 10) & Chr(10) & Mid(mystr, Pos + 1)
  25. newlinecnt = newlinecnt + 2
  26. Pos = Pos + 2
  27. End If
  28. End If
  29. Loop While Not Pos = 0
  30. xlWksht.Cells(ii + 1, 1).Value = mystr
  31.  
  32. 'xlWksht.Range("A12").Value = mystr
  33.  
  34. With xlWksht.Range(xlWksht.Cells(ii + 1, 1), xlWksht.Cells(ii + 1, 8))
  35. .HorizontalAlignment = xlLeft
  36. .VerticalAlignment = xlTop
  37. .WrapText = True
  38. .Orientation = 0
  39. .Borders(xlEdgeBottom).LineStyle = xlContinuous
  40. .Borders(xlEdgeBottom).Weight = xlThin
  41. .IndentLevel = 0
  42. .MergeCells = True
  43. .RowHeight = .Font.Size * (Len(xlWksht.Range("A" & ii + 1).text) - Len("Comments:")) / w + rht + (rht - .Font.Size) + newlinecnt * .Font.Size
  44. End With
  45.  
  46. rsin.MoveNext
  47. Loop
Thanks.
tgifgemini
Similar Threads
Reputation Points: 22
Solved Threads: 0
Junior Poster
tgifgemini is offline Offline
113 posts
since Jul 2007
Sep 13th, 2007
0

Re: vb6 - RunTime error 1004 Invalid number of arguments

Problem solved.
The "Comments" field in my input table had null values, so I fixed it with this code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If rsin![Comments] = "" Or IsNull(rsin![Comments]) Then
  2. mystr = "Comments:" & Chr(10) & "NO COMMENTS FOR THIS RECORD!"
  3. Else
  4. mystr = "Comments:" & "'" & xlApp.Clean(Trim(rsin![Comments]))
  5. End If
Thanks.
tgif
Reputation Points: 22
Solved Threads: 0
Junior Poster
tgifgemini is offline Offline
113 posts
since Jul 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB to Access connection!
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: subtract arrays type mismatch please help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC