Linear Axis Scale

Helpmeh

Member
Joined
Nov 10, 2014
Messages
13
Programming Experience
1-3
Hi,

First off, apologies if this is meant to be in the graphics parts of the forum- let me know and i will move it.

Anyway, i am creating a VB chart in a windows form, and basically no matter how hard i look, i cant find any code anywhere that allows me to force the x-axis scale to be linear.

Basically at the moment it is automatically choosing the x-axis scale based on the data. What i want it to do is in fact create the axes and then plot the data on the axis provided, or for it to just let me set the axis manually.

i have tried using the .intervals, and the constant i set it to is just displaying the corresponding number of x-axis values as a lebel on the axis rather than fixing the interval between each point.

Please help me fast! This is driving me mad! :hopelessness:
 
Now that you say it, I remember one change I did in your code when ran the test:
Private Sub CreateChart(ByRef XAxisValues() As String, YAxisValues() As String, iarrayindex As Integer)
I changed "As String" to "As Double" as convenience because it was such a hassle for me to "string quote" all my manually entered sample Double values, they needed to be numbers anyway. It didn't occur to me that some of your string values was not converted to number values. AddXY was no problem for me.

Removing "ByRef" is also something you should do there.
 
Ok, great thanks for your help.

Just as a side note, why remove ByRef? Is bad practice? I presumed that when passing values from one sub routine to another then it would require a reference?

Moving onto trendlines now, and graph interactivity - which i though would/will be the hard bit!

Thanks
 
Is bad practice?
Yes, when it has no purpose it is bad code to include it.
I presumed that when passing values from one sub routine to another then it would require a reference?
You're mixing passing mechanism with value types/reference types. ByRef is dangerous because it allows method to dereference the caller object, it is mostly used for returning multiple uncoupled value type values. Default ByVal passing copies simple values or copies the reference to object (ie a new pointer to same object).
Passing Arguments by Value and by Reference (Visual Basic)
Value Types and Reference Types
Moving onto trendlines now, and graph interactivity - which i though would/will be the hard bit!
Start a new thread if you need help with that (each topic).
 
Back
Top