Attribute VB_Name = "Module2" '***************************************************** '* Demonstration of module Gr2D.bas - A test periodic* '* signal is drawn with manual scales. * '* * '* Visual Basic 4.0 Release by J-P Moreau, Paris. * '* (www.jpmoreau.fr) * '***************************************************** Sub GrDemo() Xratio = XrIBM: Yratio = YrIBM Dim t As Double, ti As Double, tf As Double, dt As Double Dim i As Integer, ndata As Integer 'Create test signal F(t) LogX = 0: LogY = 0: EchAuto = 1 ti = 0#: tf = 0.2 ndata = InputBox("Input number of points:", "DATA", "1024") ReDim V(ndata) dt = (tf - ti) / (ndata - 1) t = ti - dt For i = 0 To ndata - 1 t = t + dt V(i) = Curve#(t) Next 'Draw a test curve with manual scales Form1.AutoRedraw = False Form1.Cls 'prepare graph Fenetre ti, tf, -100#, 100# 'window in physical coordinates Cloture 750, MaxX, 0, MaxY - 500 'screen window in pixels Grid 0.02, 10# 'draw grid Graduate 0.04, 20# 'graduate axes Axes 'draw axes Bordure 'draw frame 'draw curve (ndata points) MoveXY ti, V(1) t = ti For i = 2 To ndata - 1 t = t + dt LineXY t, V(i) Next i 'print graph caption and names of axes Form1.Font.Bold = True Form1.Font.Size = 14 Display 4500, 50, "TEST SIGNAL" Form1.Font.Size = 10 Display 900, 550, "Acc. m/s2" Display MaxX - 1250, MaxY - 400, "Time sec." 'print number of points Form1.Font.Bold = False S$ = Str$(ndata) & " points." Display 900, MaxY - 650, S$ Form1.Command1.Caption = "Continue" End Sub Function Curve#(t As Double) Dim pi As Double pi = 3.1415926535 Curve# = 10 * Sin(2 * pi * 50 * t) + 20 * Sin(2 * pi * 250 * t) + 50 * Sin(2 * pi * 500 * t) End Function