Results 1 to 6 of 6

Thread: [RESOLVED] .Line() Wrong Number of Arguments ... error

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,245

    Resolved [RESOLVED] .Line() Wrong Number of Arguments ... error

    Occasionally I get this oddball error pop up with my {form}.{picturebox}.Line () code that is more annoying than anything else.

    For example, my code can work just fine, and then while looking at a SUB or FUNC routine I get this error when executing within the IDE.

    Here is what the code may look like:

    frmChart.pctChart.Line (StartingPoint.X, StartingPoint.Y)-(EndingPoint.X, EndingPoint.Y), rgb(255, 0, 0)

    This code runs just fine. But sometimes it gets highlighted on an error break and flagged as "Wrong Number of Arguments or Invalid..."

    To get past this error, I will simply remove the space between the method (.Line) and the first "(" and run again.

    The IDE will automatically replace the space and once again everything is working without error.

    Has anyone else experienced this?

    I've seen this on several projects spanning several years over several machines and OS's, so it has to be something within the IDE itself that is just flaky.

    ??

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: .Line() Wrong Number of Arguments ... error

    Quote Originally Posted by webbiz View Post
    that is more annoying than anything else.
    Yes.

    Quote Originally Posted by webbiz View Post
    Has anyone else experienced this?
    Yes.

    It seems to be an IDE bug.

  3. #3
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: .Line() Wrong Number of Arguments ... error

    Quote Originally Posted by webbiz View Post
    Occasionally I get this oddball error pop up with my {form}.{picturebox}.Line () code that is more annoying than anything
    ...
    I've seen this on several projects spanning several years over several machines and OS's,
    so it has to be something within the IDE itself that is just flaky.
    Happened occasionally here as well...
    It has to do with the Compiler, losing its ability to map this "non-standard" call-statement -
    to the underlying methodcall of the "VB-Drawing-Interface".

    That said... in the other thread it was recommended, to forego VB-Drawing-Commands,
    and render everything via Cairo (instead of mixing VB-Drawing with Cairo-Overlays)...

    It's - in the end - the most consistent, and easiest way - e.g. the Line-Command is quite similar to VB:
    cCairoContext.DrawLine StartingPoint.X, StartingPoint.Y, EndingPoint.X, EndingPoint.Y, False, 2, RGB(255, 0, 0)

    The only difference above (regarding Parameter-Order), is the two blue marked params:
    - the 2 is apparently the LineWidth (in Pixels)
    - and False (for DrawWithinBounds) comes into play, especially with larger Line-Widths
    ..(it ensures, that no part of the Line will show up outside the "virtual Rect", the two Points span up)

    Here is some Form-Code (requiring Picture1 and Command1, as well as a reference to RC5 or RC6):
    Code:
    Option Explicit
    
    Public pic1CC As cCairoContext 'this will act as a BackBuffer to your PicBox
    
    Private Sub Form_Load() 'initialization of pic1CC requires two lines
      Picture1.ScaleMode = vbPixels
      Set pic1CC = Cairo.CreateSurface(Picture1.ScaleWidth, Picture1.ScaleHeight).CreateContext
    End Sub
    
    Sub ClearChartWith(SolidColor)
      pic1CC.Paint 1, Cairo.CreateSolidPatternLng(SolidColor)
    End Sub
    
    Sub DrawLinesOnChart()
      pic1CC.DrawLine 10, 10, 100, 100, True, 2, vbRed
      pic1CC.DrawLine 10, 100, 100, 10, True, 2, vbBlue
    End Sub
    
    Sub BackBufferToPicBox()
      Set Picture1.Picture = pic1CC.Surface.Picture
    End Sub
    
    Private Sub Command1_Click()
      ClearChartWith vbWhite
          DrawLinesOnChart
          '... other routines which contribute
      BackBufferToPicBox 'final "take-over" of the cairo-based backbuffer
    End Sub
    It shouldn't be that hard, to swap out your picBox.Line calls, vs. picCC.DrawLine calls.
    (after doing some "BackBuffer-mappings" like shown in the Form_Load of above code).

    HTH

    Olaf

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,245

    Re: .Line() Wrong Number of Arguments ... error

    Quote Originally Posted by Schmidt View Post
    Happened occasionally here as well...
    It has to do with the Compiler, losing its ability to map this "non-standard" call-statement -
    to the underlying methodcall of the "VB-Drawing-Interface".

    That said... in the other thread it was recommended, to forego VB-Drawing-Commands,
    and render everything via Cairo (instead of mixing VB-Drawing with Cairo-Overlays)...

    It's - in the end - the most consistent, and easiest way - e.g. the Line-Command is quite similar to VB:
    cCairoContext.DrawLine StartingPoint.X, StartingPoint.Y, EndingPoint.X, EndingPoint.Y, False, 2, RGB(255, 0, 0)

    The only difference above (regarding Parameter-Order), is the two blue marked params:
    - the 2 is apparently the LineWidth (in Pixels)
    - and False (for DrawWithinBounds) comes into play, especially with larger Line-Widths
    ..(it ensures, that no part of the Line will show up outside the "virtual Rect", the two Points span up)

    Here is some Form-Code (requiring Picture1 and Command1, as well as a reference to RC5 or RC6):
    Code:
    Option Explicit
    
    Public pic1CC As cCairoContext 'this will act as a BackBuffer to your PicBox
    
    Private Sub Form_Load() 'initialization of pic1CC requires two lines
      Picture1.ScaleMode = vbPixels
      Set pic1CC = Cairo.CreateSurface(Picture1.ScaleWidth, Picture1.ScaleHeight).CreateContext
    End Sub
    
    Sub ClearChartWith(SolidColor)
      pic1CC.Paint 1, Cairo.CreateSolidPatternLng(SolidColor)
    End Sub
    
    Sub DrawLinesOnChart()
      pic1CC.DrawLine 10, 10, 100, 100, True, 2, vbRed
      pic1CC.DrawLine 10, 100, 100, 10, True, 2, vbBlue
    End Sub
    
    Sub BackBufferToPicBox()
      Set Picture1.Picture = pic1CC.Surface.Picture
    End Sub
    
    Private Sub Command1_Click()
      ClearChartWith vbWhite
          DrawLinesOnChart
          '... other routines which contribute
      BackBufferToPicBox 'final "take-over" of the cairo-based backbuffer
    End Sub
    It shouldn't be that hard, to swap out your picBox.Line calls, vs. picCC.DrawLine calls.
    (after doing some "BackBuffer-mappings" like shown in the Form_Load of above code).

    HTH

    Olaf
    Olaf - Had DM'd you the other day to say 'hey' and see if you were still around. You were very helpful to me back when I was a young man and now I'm an old man and semi-retired. So I'm glad to see you are still at it. I left VB6 years ago and only recently returned to update some old apps I still heavily rely on for market analysis.

    I've been working with the RC and Cairo files the past couple of days trying to get a handle on it. As I'm not a programmer by trade, the depth of working with the API, GDI or whatever advanced graphics are is something I barely touched as time had always been against me in getting things done. Having a little more time now and a need for speed, I have been digging deep into the API over the past 36 hours and wish I had gone that route in the first place. As suggested by you and another member here, I will be systematically replacing the VB graphic code in my app that is slow over to API calls and most likely by using the Cairo functions once I get it clear in my head.

    I didn't find any in-depth documentation on it but have been reading the comments within the cairo tutorial examples which has been helpful. It does leave some things unexplained though that perhaps a pro would take for granted, but I'm no pro. ;-0

    I won't go into what I'm struggling with here because there is already another thread I still have open on the subject and this thread was just an inquiry as to LINE() acting funky.

    Thanks for explaining the issue on that. I'll definitely be replacing those LINE routines!

    Good to see you are still active. I had envisioned years ago that you were older than I (maybe cuz yer so smart) when I was much younger, so maybe not? Cuz I'm getting old and ugly by the second. LOL!

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,245

    Re: .Line() Wrong Number of Arguments ... error

    Quote Originally Posted by Schmidt View Post

    It shouldn't be that hard, to swap out your picBox.Line calls, vs. picCC.DrawLine calls.
    (after doing some "BackBuffer-mappings" like shown in the Form_Load of above code).

    HTH

    Olaf
    I just took a look at all my routines that use the picturebox LINE() to draw my bars and lines and noticed that the picturebox SCALEMODE is Twips.

    All my X/Y function routines that provide references on the chart are based on Twips.

    Me thinks changing these Line() code lines over to .DrawLine calls are not going to be that easy. I'm going to have to change all the scales to pixels, right? I have lots of code lines that have work off ratios of the scales such as this line...

    sngVolInterval = (frmChart.pctChart.ScaleHeight * 0.095) / gMaxVol

    Oh my my...

  6. #6
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: .Line() Wrong Number of Arguments ... error

    Quote Originally Posted by webbiz View Post

    sngVolInterval = (frmChart.pctChart.ScaleHeight * 0.095) / gMaxVol
    I'd try to replace all occurences of your 0.095 with a Const-Definition, as e.g.:
    Const ScaleFacY As Double = 0.095

    ...and then switch to Pixel-Scalemode and change the Const to:
    Const ScaleFacY As Double = 1.0 '<- or if that's too small, then 1.2 or 1.4

    in a first attempt, to "visualize something"...

    Also not sure currently, whether you use (and work around) the default Top-Down-Coordsys -
    or whether you want a Bottom-Up-Coordsys (where y = 0 is at the Bottom of the Canvas).

    There's a whole lot which can be done in this regard also with Cairos Translate+Scale-Matrices,
    but why not make a fast try with the simple "Const-Factor" first.
    (you don't even have to change to Cairo in such a first attempt, just switch the PicBox to Scalemode vbPixels,
    and use your original picBox.Line-calls with the already mentioned ScaleFacY "around 1", to see if this works.

    If that doesn't work as you imagined it, then I'd recommend, that
    you post some of your Data in a *.csv- or *.txt-file ...
    (to be able to make an entire Cairo-based example for that data).

    Olaf

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width