Results 1 to 20 of 20

Thread: [RESOLVED] [HELP] Read from array.

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Location
    India
    Posts
    45

    Resolved [RESOLVED] [HELP] Read from array.

    Well i have attached a .cls file.. This performs linear regression operation..
    I have an array with me MyArray(,)..
    Now this is a 2 D array..
    Wat i need to do is i need to read from the array and have to Calculate:
    log(0.931227737/MyArray(i,j)) and store this in a new array.. MyArrayX()
    Similarly i got to do for each of the value in the array..

    And i got to read the MyArray(,) and calculate:
    log(MyArray(i,j)) and store this in new arra.. MyArrayY()..
    Now for the linear regression, we need to pass the X and Y value when we call the class..

    The following is the code i got from the net.. Here the class is called when we click on the form..

    Instead i need to call the class when we pass each of the values in the arrays..

    That is when we call the class, the x value would be MyArrayX(0,0) and the corresponding y value that is passed would be MyArrayY(0,0).. Similarly MyArrayX(1,0) etc..


    VB Code:
    1. Option Explicit
    2.  
    3. Private Type PointType
    4.   X As Double
    5.   Y As Double
    6. End Type
    7.  
    8. Dim Reg As New RegressionObject
    9.  
    10. Const R = 100
    11. Dim P(1 To 200) As PointType
    12.  
    13. Private Sub Form_Load()
    14.   Reg.Degree = 3
    15. End Sub
    16.  
    17. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    18.   With Reg
    19.     .XYAdd X, Y
    20.     P(.XYCount).X = X
    21.     P(.XYCount).Y = Y
    22.     Redraw
    23.   End With
    24. End Sub
    25.  
    26. Private Sub Redraw()
    27. Dim i&
    28.   Cls
    29.   With Reg
    30.     For i = 1 To .XYCount
    31.       Circle (P(i).X, P(i).Y), R
    32.     Next i
    33.     CurrentX = ScaleLeft
    34.     CurrentY = .RegVal(CDbl(ScaleLeft))
    35.     For i = ScaleLeft To ScaleWidth Step R
    36.       Line -(i, .RegVal(CDbl(i))), vbBlue \ 2
    37.     Next i
    38.   End With
    39. End Sub
    40. Option Explicit
    41.  
    42. Private Type PointType
    43.   X As Double
    44.   Y As Double
    45. End Type
    46.  
    47. Dim Reg As New RegressionObject
    48.  
    49. Const R = 100
    50. Dim P(1 To 200) As PointType
    51.  
    52. Private Sub Form_Load()
    53.   Reg.Degree = 3
    54. End Sub
    55.  
    56. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    57.   With Reg
    58.     .XYAdd X, Y
    59.     P(.XYCount).X = X
    60.     P(.XYCount).Y = Y
    61.     Redraw
    62.   End With
    63. End Sub
    64.  
    65. Private Sub Redraw()
    66. Dim i&
    67.   Cls
    68.   With Reg
    69.     For i = 1 To .XYCount
    70.       Circle (P(i).X, P(i).Y), R
    71.     Next i
    72.     CurrentX = ScaleLeft
    73.     CurrentY = .RegVal(CDbl(ScaleLeft))
    74.     For i = ScaleLeft To ScaleWidth Step R
    75.       Line -(i, .RegVal(CDbl(i))), vbBlue \ 2
    76.     Next i
    77.   End With
    78. End Sub

    So wat changes to be made here so that i can perform the action(call the class) wheni click a command button and pass the x and y values as i want it to...

    Please help me with this..
    I hope i'v made things clear.

    Ricky
    Attached Files Attached Files

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