Solved

Convert VB6 "Drawing" code to VB.Net

Posted on 2008-06-22
5
2,301 Views
Last Modified: 2013-11-26
I need to convert the following VB6 code in VB.Net.   Can someone please help me
Public Sub DrawSheet()

		Dim j As Object

		Dim NewLargeChange As Short

		Dim X, n As Short

		

		gsy = ClientRectangle.Height / 100

		ChartScrolFactor = 75

		

		With VScroll1

			.Left = ClientRectangle.Width - .Width

			.Height = ClientRectangle.Height '- 41

			.SmallChange = ChartScrolFactor

			If Int((LastBuf / ChartTimeInc) / 100) > 10 * .SmallChange Then

				NewLargeChange = Int((LastBuf / ChartTimeInc) / 100)

				.Maximum = .Maximum + NewLargeChange - .LargeChange

				.LargeChange = NewLargeChange '* ChartScrolFactor + 1

			Else

				NewLargeChange = 10 * .SmallChange

				.Maximum = .Maximum + NewLargeChange - .LargeChange

				.LargeChange = NewLargeChange

			End If

		End With

		RecInd.Left = ClientRectangle.Width - 55 : RecInd.Top = 0

		

		ChartScreenWidth = ClientRectangle.Width - VScroll1.Width - 50

		

		X = System.Math.Abs(Int((ChartScaleMin - ChartScaleMax) / ChartScaleMajorInc)) ' + 1

		ChartScreenMajorInc = ChartScreenWidth / X

		

		ChartScreenMinorInc = ChartScreenMajorInc * (ChartScaleMinorInc / ChartScaleMajorInc)

		

		ChartScreenFactor = ChartScreenWidth / (ChartScaleMajorInc * X) 'pixels/div

		ChartScreenZero = 1 + (0 - ChartScaleMin) * ChartScreenFactor

		'draw header

		ForeColor = System.Drawing.ColorTranslator.FromOle(&H0)

		'UPGRADE_WARNING: Couldn't resolve default property of object j. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'

		j = -1

		HeaderHeight = 15

		'UPGRADE_ISSUE: Form property VcrCal.AutoRedraw was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

        'Me.AutoRedraw = True

		'UPGRADE_ISSUE: Form method VcrCal.Cls was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

        'Cls()

		For n = 1 To ChartScreenWidth Step ChartScreenMajorInc

			'UPGRADE_ISSUE: Form method VcrCal.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

            Me.Line (n, 1) - (n, HeaderHeight)

			'UPGRADE_WARNING: Couldn't resolve default property of object j. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'

			j = j + 1

			'UPGRADE_ISSUE: Form property VcrCal.CurrentX was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			CurrentX = n

			'UPGRADE_ISSUE: Form property VcrCal.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			CurrentY = 2

			'UPGRADE_WARNING: Couldn't resolve default property of object j. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'

			'UPGRADE_ISSUE: Form method VcrCal.Print was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			Print(Trim(Str(Int(ChartScaleMin + ChartScaleMajorInc * j))))

		Next n

		

		

		Call CalChartUpdate()

	End Sub

	'LastBuf: last record number in file buffer array

	'ScrolVal: number of vert divisions to scroll down

	Public Sub CalChartUpdate()

		Dim tStamp As Object

		Dim Failsub As Short

		Dim bX2, aX2, aX1, bX1 As Single

		Dim d, j As Short

		Dim n, k As Integer

		Dim Graphindx As Integer

		Dim CurrentTime As Date

		Dim ScrolVal As Short

		Dim VtInc As Single

		

		

		On Error GoTo esub

		ForeColor = System.Drawing.ColorTranslator.FromOle(&HFFFF80) ' Set foreground color.

		'UPGRADE_ISSUE: Form property VcrCal.ScaleMode is not supported. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="8027179A-CB3B-45C0-9863-FAA1AF983B59"'

		ScaleMode = 3 ' Set ScaleMode to pixels.

		'UPGRADE_ISSUE: Form property VcrCal.DrawWidth was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		DrawWidth = 1 ' Set DrawWidth.

		'UPGRADE_ISSUE: Form property VcrCal.DrawStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		DrawStyle = 0

		'UPGRADE_ISSUE: Form property VcrCal.AutoRedraw was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		Me.AutoRedraw = False

		'UPGRADE_ISSUE: Form method VcrCal.Cls was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		Cls()

		j = UBound(CalData) - (ChartRoll - 1) 'set j

		'init variables

		ScrolVal = (Int(VScroll1.Value)) ' / ChartScrolFactor)) '* ChartTimeInc)

		VtInc = gsy

		'GoTo nogrid

		'draw markers

		If System.Math.Abs(yPos1 - yPos2) < 5 Then

			ForeColor = System.Drawing.Color.Red

			'UPGRADE_ISSUE: Form property VcrCal.DrawWidth was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			DrawWidth = 2 : yPos2 = yPos1

		End If

		'UPGRADE_ISSUE: Form method VcrCal.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		Me.Line (1, yPos1) - (ClientRectangle.Width, yPos2), B

		'UPGRADE_ISSUE: Form property VcrCal.DrawWidth was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		DrawWidth = 1 : ForeColor = System.Drawing.ColorTranslator.FromOle(&HFFFF80)

		'vert grid

		'UPGRADE_ISSUE: Form property VcrCal.DrawWidth was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		DrawWidth = 1 : ForeColor = System.Drawing.ColorTranslator.FromOle(&HFFFF80)

		For n = HeaderHeight To ClientRectangle.Height Step gsy

			If n > yPos1 + 2 Or n < yPos1 - 2 Then

				'UPGRADE_ISSUE: Form method VcrCal.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

				Me.Line (1, n) - (ChartScreenWidth, n)

			Else

			End If

		Next n

		'horiz grid

		'UPGRADE_ISSUE: Form property VcrCal.DrawStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		DrawStyle = 2

		For n = 1 To ChartScreenWidth Step ChartScreenMinorInc

			'UPGRADE_ISSUE: Form method VcrCal.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			Me.Line (n, HeaderHeight) - (n, ClientRectangle.Height)

		Next n

		

		'UPGRADE_ISSUE: Form property VcrCal.DrawStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		DrawStyle = 0

		'UPGRADE_ISSUE: Form property VcrCal.DrawWidth was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		DrawWidth = 2

		For n = 1 To ChartScreenWidth Step ChartScreenMajorInc

			'UPGRADE_ISSUE: Form method VcrCal.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			Me.Line (n, HeaderHeight) - (n, ClientRectangle.Height)

			'UPGRADE_ISSUE: Form property VcrCal.CurrentX was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			CurrentX = n

			'UPGRADE_ISSUE: Form property VcrCal.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			CurrentY = 5

		Next n

		n = j

		'draw time

		ForeColor = System.Drawing.ColorTranslator.FromOle(&HC0C000)

		

		n = j - 2 : d = 0

		Do While d < 300 + ChartRoll

			d = d + 1

			If n > UBound(CalData) Then n = 0

			If Int(Second(CalData(n).RecTime) / 15) = Second(CalData(n).RecTime) / 15 Then

				If Minute(CalData(n).RecTime) + Second(CalData(n).RecTime) <> k Then 'where d= last known hour and minute stamp

					k = Minute(CalData(n).RecTime) + Second(CalData(n).RecTime)

					'UPGRADE_WARNING: Couldn't resolve default property of object tStamp. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'

					tStamp = VB.Right("0" & Trim(Str(Hour(CalData(n).RecTime))), 2) & ":" & VB.Right("0" & Trim(Str(Minute(CalData(n).RecTime))), 2) & ":" & VB.Right("0" & Trim(Str(Second(CalData(n).RecTime))), 2)

					'UPGRADE_ISSUE: Form property VcrCal.CurrentX was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

					CurrentX = ClientRectangle.Width / 2

					'UPGRADE_ISSUE: Form property VcrCal.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

					CurrentY = ((CalData(n).Indx - ScrolVal) * gsy) + HeaderHeight

					'UPGRADE_WARNING: Couldn't resolve default property of object tStamp. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'

					'UPGRADE_ISSUE: Form method VcrCal.Print was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

					VcrCal.Print(tStamp)

				End If

			End If

			n = n + 1

			'UPGRADE_ISSUE: Form property VcrCal.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			If CurrentY > ClientRectangle.Height Then

				Exit Do

			End If

		Loop 

nogrid: 

		'UPGRADE_ISSUE: Form property VcrCal.DrawWidth was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		DrawWidth = 4

		n = j - 2 : d = 0

		Do While d < 300 + ChartRoll

			d = d + 1

			If n > UBound(CalData) Then n = 0

			'UPGRADE_ISSUE: Form property VcrCal.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			CurrentY = ((CalData(n).Indx - ScrolVal) * gsy) + HeaderHeight

			Select Case CalData(n).Mode

				Case 0 ' GC_Sample + CC_TC * 2'vbWhite       &HFFFFFF

					ForeColor = System.Drawing.ColorTranslator.FromOle(&HC00000) 'vbBlue

				Case 1

					ForeColor = System.Drawing.ColorTranslator.FromOle(&HC0) 'vbRed

				Case 2

					ForeColor = System.Drawing.ColorTranslator.FromOle(&HC000) 'vbGreen

				Case 3

					ForeColor = System.Drawing.ColorTranslator.FromOle(&HC0C0) 'vbYellow

			End Select

			'UPGRADE_ISSUE: Form property VcrCal.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			'UPGRADE_ISSUE: Form method VcrCal.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			Me.Line (6, CurrentY) - (6, CurrentY + gsy)

			n = n + 1

			'UPGRADE_ISSUE: Form property VcrCal.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

			If CurrentY > ClientRectangle.Height Then Exit Do

			'If n = j - 2 Then Exit Do

		Loop 

		'draw graphs

		'Exit Sub

		n = j - 2

		Do  'find latest annalog reading channel 1

			If n > UBound(CalData) Then

				n = 0 : Failsub = Failsub + 1

			End If

			If Failsub > 1 Then

				Exit Sub

			End If

			If CalData(n).ChannelID = 1 Then

				aX1 = CalData(n).Value * (ChartScreenFactor / Atten) + ChartScreenZero

				Exit Do

			End If

			n = n + 1

		Loop Until Failsub = 2

		n = j - 2

		Do  'find latest annalog reading channel 5

			If n > UBound(CalData) Then n = 0

			If CalData(n).ChannelID = 8 Then

				bX1 = CalData(n).Value * (ChartScreenFactor) + ChartScreenZero

				Exit Do

			End If

			n = n + 1

			If n > UBound(CalData) Then Exit Do

		Loop 

		

		n = j : d = 0

		Do While d < 300 + ChartRoll 'draw pen 1 and 2, depth markers, depth labels

			d = d + 1

			If n > UBound(CalData) Then n = 0

			Select Case Val(CStr(CalData(n).ChannelID))

				Case 1 'draw pen 1

					ForeColor = System.Drawing.ColorTranslator.FromOle(QBColor(1))

					'UPGRADE_ISSUE: Form property VcrCal.DrawWidth was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

					DrawWidth = 1

					aX2 = CalData(n).Value * (ChartScreenFactor / Atten) + ChartScreenZero

					'UPGRADE_ISSUE: Form method VcrCal.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

					Me.Line (aX1, ((CalData(n).Indx - 1 - ScrolVal) * VtInc) + HeaderHeight) - (aX2, ((CalData(n).Indx - ScrolVal) * VtInc) + HeaderHeight)

					aX1 = aX2

				Case 8 'draw pen 2

					ForeColor = System.Drawing.ColorTranslator.FromOle(QBColor(12))

					'UPGRADE_ISSUE: Form property VcrCal.DrawWidth was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

					DrawWidth = 1

					bX2 = CalData(n).Value * (ChartScreenFactor) + ChartScreenZero

					'UPGRADE_ISSUE: Form method VcrCal.Line was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

					Me.Line (bX1, ((CalData(n).Indx - 1 - ScrolVal) * VtInc) + HeaderHeight) - (bX2, ((CalData(n).Indx - ScrolVal) * VtInc) + HeaderHeight)

					bX1 = bX2

			End Select

			n = n + 1

			If (CalData(n - 1).Indx - ScrolVal) * VtInc > ClientRectangle.Height Then

				Exit Do

			End If

		Loop 

esub: 

		'Debug.Print Err.Number

		'UPGRADE_ISSUE: Form property VcrCal.AutoRedraw was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

		Me.AutoRedraw = True

	End Sub

Open in new window

0
Comment
Question by:CKirby18
  • 3
5 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 21841890
Hi CKirby18,

Unfortunately there is NO DIRECT conversion for your code.  =\

The drawing mechanism is one the aspects of VB that underwent a MAJOR methodology change when it became part of the .Net family.

You have two basic options to deal with graphics:

(1) Draw on a Bitmap that is being displayed by the Image() property of something.
(2) Store the drawing information in some kind of structure and display it using the Paint() event of some Control.

Either method will utilize a Graphics surface on which you will draw.  In method #1, you explicitly create one from the Bitmap you are drawing on.  In method #2, it is supplied for you as a parameter in the Paint() event.

Print() method would be replaced with Graphics.DrawString().
Line() method would be replaced with Graphics.DrawLine().
DrawStyle/DrawMode is a little trickier depending on what you are doing.  They ~can~ be replaced with custom Pens/Brushes...but again it depends on what the original code was doing.

I think you're best bet would be to describe in PLAIN ENGLISH what the original VB6 code was supposed to do and then post some screenshots of its output.

~IM
0
 

Author Comment

by:CKirby18
ID: 21842254
The original code is used to display gathered data in a graph.  The original programmer did everything in VB6, and is nowhere to be found.  I have been given his software so that I can change and improve some things.  However, I have worked only w/ .Net and never VB6.  I have become quite skilled at what I do in .Net, but I have never done anything that has required be to make use of drawing objects in this manner, so unfortunately I am but a novice in this area.  

I have included to images below.  The first image is what the form looks like at design time and the second, at runtime.  

I greatly appreciate any assistance that anyone can give me on this matter and if possible, any kind of code that would allow me to produce such a graph would be an enormous help as this aspect of the project is the only area that I cannot handle by myself.  As I'm sure you all know, it always takes much longer to become familiar with a new area of coding by yourself than it does to learn from someone else's example.  Also, I am on a tight time frame with this project and it is going to be very hard for me to learn this part of the programming from scratch and still meet my deadline.

Thank you very very much in advance and let me know if there is any more information that I can provide to help you guys out!!! :)
Form-Design.JPG
Form-Runtime.JPG
0
 

Author Comment

by:CKirby18
ID: 21842351
I know it is lengthy, but I decided to go ahead and paste the rest of the code from the form just in case it would make anything easier.  This is the original VB6 code.
VERSION 5.00

Begin VB.Form Vcr1 

   Appearance      =   0  'Flat

   AutoRedraw      =   -1  'True

   BackColor       =   &H00FFFFFF&

   Caption         =   "Chart"

   ClientHeight    =   6816

   ClientLeft      =   60

   ClientTop       =   -2676

   ClientWidth     =   8160

   ControlBox      =   0   'False

   FillColor       =   &H00C0FFFF&

   FillStyle       =   0  'Solid

   FontTransparent =   0   'False

   Icon            =   "vcr.frx":0000

   LinkTopic       =   "Form1"

   MaxButton       =   0   'False

   MinButton       =   0   'False

   NegotiateMenus  =   0   'False

   ScaleHeight     =   568

   ScaleMode       =   3  'Pixel

   ScaleWidth      =   680

   StartUpPosition =   2  'CenterScreen

   Visible         =   0   'False

   Begin VB.Timer DispRefreshTimer 

      Interval        =   999

      Left            =   6960

      Top             =   6120

   End

   Begin VB.VScrollBar VScroll1 

      CausesValidation=   0   'False

      Height          =   6570

      LargeChange     =   50

      Left            =   7800

      TabIndex        =   0

      TabStop         =   0   'False

      Top             =   0

      Width           =   225

   End

   Begin VB.Label RecInd 

      Alignment       =   2  'Center

      BackColor       =   &H000000FF&

      Caption         =   "REC"

      BeginProperty Font 

         Name            =   "MS Sans Serif"

         Size            =   9.6

         Charset         =   0

         Weight          =   700

         Underline       =   0   'False

         Italic          =   0   'False

         Strikethrough   =   0   'False

      EndProperty

      ForeColor       =   &H0080FFFF&

      Height          =   255

      Left            =   7200

      TabIndex        =   1

      Top             =   0

      Visible         =   0   'False

      Width           =   615

   End

   Begin VB.Menu DisplayReal 

      Caption         =   "Run"

      Enabled         =   0   'False

      Begin VB.Menu StartScan 

         Caption         =   "Start"

      End

      Begin VB.Menu StopScan 

         Caption         =   "Stop"

         Enabled         =   0   'False

      End

   End

   Begin VB.Menu CalMode 

      Caption         =   "Calibration"

   End

   Begin VB.Menu DilutionControls 

      Caption         =   "Dilution"

      Begin VB.Menu DilutionValveOpen 

         Caption         =   "On"

         Enabled         =   0   'False

      End

      Begin VB.Menu DilutionValveClosed 

         Caption         =   "Off"

         Enabled         =   0   'False

      End

      Begin VB.Menu SetDilution 

         Caption         =   "Set"

      End

   End

   Begin VB.Menu RecordingOnOff 

      Caption         =   "Record"

      Enabled         =   0   'False

      Begin VB.Menu StartRecording 

         Caption         =   "Start Recording"

      End

      Begin VB.Menu StopRecording 

         Caption         =   "Stop Recording"

         Enabled         =   0   'False

      End

   End

   Begin VB.Menu AddAnnotation 

      Caption         =   "Chart"

      Index           =   0

      Begin VB.Menu ChartdisplaySettings 

         Caption         =   "Chart Settings"

      End

      Begin VB.Menu ChartInput 

         Caption         =   "ChartNotes"

         Begin VB.Menu DepthLagChange 

            Caption         =   "Set Depth Lag"

         End

         Begin VB.Menu DepthChange 

            Caption         =   "Set Depth"

         End

         Begin VB.Menu CallLithogDialog 

            Caption         =   "Add Lithography"

            Enabled         =   0   'False

            Index           =   0

         End

         Begin VB.Menu AddOperatorNote 

            Caption         =   "Operator Note"

            Enabled         =   0   'False

            Index           =   0

         End

      End

   End

   Begin VB.Menu ExportMenu 

      Caption         =   "Export"

      Begin VB.Menu ExportLogPlot 

         Caption         =   "Log Plot"

      End

      Begin VB.Menu ExportText 

         Caption         =   "Text"

         Enabled         =   0   'False

      End

   End

   Begin VB.Menu CloseChartWindow 

      Caption         =   "Close"

   End

End

Attribute VB_Name = "Vcr1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Public xPos1 As Single, yPos1 As Single, xPos2 As Single, yPos2 As Single, lastWindowState As Integer

Public ChartScaleMajorInc As Single, ChartScaleMinorInc As Single, ChartScaleMin As Single, ChartScaleMax As Single, ChartTimeInc As Single, ChartDepthInc As Single

Dim GraphPeaks(15, 1) As Double

Dim DispData() As RecData

Dim Pens(15, 1) As Double

Dim PenColor(15) As Long

Dim ChartScreenWidth As Single, ChartScreenFactor As Single, ChartScreenZero As Single, ChartScreenMajorInc As Single, ChartScreenMinorInc As Single

Dim ScrollStep As Long, HeaderHeight As Integer, gsy As Single, pageno As Integer
 

Private Sub AddOperatorNote_Click(Index As Integer)

 diaOperatorNotes.Show 1

End Sub
 

Private Sub CallLithogDialog_Click(Index As Integer)

 LithographyDialog.Show 1

End Sub
 

Private Sub CalMode_Click()

 Dim resp As Long

 AnalogIncData.AnalogDataTimer.Enabled = False

 resp = RunPumpCounters(False)

 AnalogIncData.AuxDataTimer.Enabled = False

 Me.Hide

 DashBoard.Hide

 DataGrid.Hide

 VcrCal.Show

End Sub
 

Private Sub ChartdisplaySettings_Click()

 Dim offset As Long

 diaChartSetup.Show 1

 MousePointer = vbHourglass

 offset = LastBuf

 pageno = 0

 Call FillDispArray(offset)

 VScroll1.Value = VScroll1.Min

 Form_Resize

 MousePointer = vbDefault

End Sub
 
 

Private Sub CloseChartWindow_Click()

 Dim resp As Long

 AnalogIncData.AnalogDataTimer.Enabled = False

 resp = RunPumpCounters(False)

 AnalogIncData.AuxDataTimer.Enabled = False

 pageno = 0

 If REC = True Then Call StopRecording_Click

 If REC = True Then Exit Sub

 Call StopScan_Click

 Call ClearChartData

 Call ClearDashBoard

 DashBoard.Hide

 DataGrid.Hide

 Me.Hide

 AnalogIncData.Show

End Sub
 

Private Sub cmdReset_Click(Index As Integer)

 AnalogIncData.AnalogDataTimer.Enabled = True

End Sub

Private Sub ChartInput_Click()

 If REC = True Then

  DepthLagChange.Enabled = True

  DepthChange.Enabled = True

 Else

  'DepthLagChange.Enabled = False

  'DepthChange.Enabled = False

 End If

End Sub
 

Private Sub DepthChange_Click()

 diaSetDepth.Show 1

End Sub
 

Private Sub DepthLagChange_Click()

 diaSetDepthLag.Show 1

End Sub
 

Private Sub DilutionValveClosed_Click()

 DilutionValveOpen.Enabled = True

 DilutionValveClosed.Enabled = False

 

 OMUX_Address = 1

 OMUX_Pos(0) = 1

 OMUX_Pos(1) = -1

 OMUX_Cmd = DeactivateDigitalOutputs

 Call OptomuxDriver(SimDat)

 Dilution = 1

 If REC = True Then

  If OMUX_Error = 0 Then

    Call WriteRec(24, 100, &H25, REC)

  End If

 End If
 

End Sub
 

Private Sub DilutionValveOpen_Click()

 Dim erc As Integer

 DilutionValveOpen.Enabled = False

 DilutionValveClosed.Enabled = True

 

 OMUX_Address = 1

 OMUX_Pos(0) = 1

 OMUX_Pos(1) = -1

 OMUX_Cmd = ActivateDigitalOutputs

 Call OptomuxDriver(SimDat)

 Dilution = Abs(Round(Val(diaSetDilution.Text1.Text), 2))
 

 If REC = True Then

  If OMUX_Error = 0 Then

   Call WriteRec(24, Dilution * 100, &H25, REC)

  End If

 End If
 

End Sub

Private Sub SetDilution_Click()

 diaSetDilution.Show 1, Vcr1

 If Val(diaSetDilution.Text1.Text) <> 0 And DilutionValveClosed.Enabled = False Then DilutionValveOpen.Enabled = True

End Sub
 

Private Sub ExportLogPlot_Click()

 diaExportLogPlot.Show

End Sub
 

Private Sub Form_Click()

' Call ChartUpdate

End Sub
 
 

Private Sub StartScan_Click()

 Dim resp As Long

 If Connected = True Then

  AnalogIncData.AnalogDataTimer.Enabled = True

  resp = RunPumpCounters(True)

  AnalogIncData.AuxDataTimer.Enabled = True

  GC_Sample = -1

  CC_TC = -1

  StopScan.Enabled = True

  StartScan.Enabled = False

 End If

End Sub

Private Sub StopScan_Click()

 Dim resp As Long

  AnalogIncData.AnalogDataTimer.Enabled = False

  resp = RunPumpCounters(False)

  AnalogIncData.AuxDataTimer.Enabled = False

  StopScan.Enabled = False

  StartScan.Enabled = True

  GC_Sample = -1

  CC_TC = -1

End Sub
 

Private Sub Form_Activate()

 Dim n As Integer, OpResp As VbMsgBoxResult

 CalValid = True

 If CalibrationDue - Date + Time <= 0 Then

  'prompt for cal

 End If

 For n = 1 To 5

  If CalFactors(n, 1) = 0 Then CalValid = False

 Next n

 For n = 2 To 5

  If CalFactors(n, 3) = 0 Then CalValid = False

 Next n

 For n = 14 To 15

  If CalFactors(n, 1) = 0 Then CalValid = False

 Next n

 If CalValid = False Then

  Vcr1.Hide

  OpResp = MsgBox("Calibration information missing or invalid !" + vbCrLf + "Calibation must be completed to continue" + vbCrLf + "Press 'OK' to continue with calibration or " + vbCrLf + "Press 'Cancel' to close file and return to main menu", vbOKCancel, "Critical Error")

  

  If OpResp = vbCancel Then

   'Vcr1.Hide

   'Close #hdlPumpFile

   Close #hdlProjFile

   Close #hdlChartRecFile

   Call ClearChartData

   Call ClearDashBoard

   Call InitScale

   AnalogIncData.Show

  Else

   VcrCal.Show

  End If

   GoTo esub

 End If

 DashBoard.Refresh

 DataGrid.Refresh

 Call DrawSheet

esub:

End Sub
 

Private Sub Form_GotFocus()

' Call ChartUpdate

End Sub
 

Private Sub StartRecording_Click()

 Dim resp As Long

 If Connected = False Then Call OptoConnect

 If Omux_Fail = True Then

  Call MsgBox("NO RESPONCE FROM I/O" + vbCrLf + "Recording function failed!" + vbCrLf + "Check Opto22 components", vbCritical)

  RecDate = Date + Time

  hdlProjFile = FreeFile

  Open ActiveFileName + ".adp" For Append As #hdlProjFile

  Print #hdlProjFile, "Recording Failed to start" + Str(RecDate)

  Close hdlProjFile

  Omux_Fail = False

  OptoDisconnect

  Exit Sub

 End If

 Call StartScan_Click

 Call GetOutPutFile

 REC = True

 RecInd.Visible = True

 StopRecording.Enabled = True

 StartRecording.Enabled = False

 RecDate = Date + Time

 hdlProjFile = FreeFile

 Open ActiveFileName + ".adp" For Append As #hdlProjFile

 Print #hdlProjFile, "Recording started  " + Str(RecDate)

 Close hdlProjFile

End Sub

Private Sub StopRecording_Click()

 Dim OpResp, hdlProjFile As Long, resp As Long, RecDate As Date

 OpResp = MsgBox("Warning! when recording stops all CC/TC and Hotwire ChartData" + vbCrLf + _

             "will be ignored. Pump stroke counts and Depth markers will" + vbCrLf + _

             "continue to be stored and may be added to ChartData file when" + vbCrLf + _

             "recording is resumed. Are you sure you want to stop recording ?", vbYesNo, "Stop Recording")

 If OpResp <> vbYes Then GoTo moreChart

                            

 'OptoDisconnect

 REC = False

 RecInd.Visible = False

 StopRecording.Enabled = False

 StartRecording.Enabled = True

 

 RecDate = Date + Time

 hdlProjFile = FreeFile

 Open ActiveFileName + ".adp" For Append As #hdlProjFile

 Print #hdlProjFile, "Recording stopped  " + Str(RecDate)

 Print #hdlProjFile, "At depth reading " + Str(CurrentDepth) + " feet"

 Close hdlProjFile

 Close hdlRecFile

Exit Sub

moreChart:

Vcr1.Show
 

End Sub
 

Private Sub Form_Load()

 Call ReloadForm

' With Vcr1

'  .Top = Screen.Height / 25

'  .Left = Screen.Width / 25

'  .Height = Screen.Height - (Screen.Height / 10)

'  .Width = Screen.Width - (Screen.Width / 10)

' End With

End Sub
 

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

 xPos1 = X: yPos1 = Y

End Sub
 

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

 xPos2 = X: yPos2 = Y

 If Button = 2 Then

  PopupMenu ChartInput

 Else

  Call ChartUpdate

 End If

End Sub
 

Private Sub Form_Resize()

 'If Vcr1.WindowState = 0 Then Exit Sub

 lastWindowState = Vcr1.WindowState

Call DrawSheet

End Sub
 

Public Sub DrawSheet()

 Dim X As Integer, n As Integer

 'init variables

 gsy = ScaleHeight / 100

 ChartScreenWidth = ScaleWidth - VScroll1.Width - 50

 With VScroll1

  .Left = ScaleWidth - .Width

  .Height = ScaleHeight '- 41

  .SmallChange = 5

  If Int((LastBuf / ChartTimeInc) / 100) > 10 * .SmallChange Then

   .LargeChange = Int((LastBuf / ChartTimeInc) / 100)

  Else

   .LargeChange = 10 * .SmallChange

  End If

 End With

 RecInd.Left = ScaleWidth - 55: RecInd.Top = 0

 X = Abs(Int((ChartScaleMin - ChartScaleMax) / ChartScaleMajorInc)) + 1

 ChartScreenMajorInc = ChartScreenWidth / X

 ChartScreenMinorInc = ChartScreenMajorInc * (ChartScaleMinorInc / ChartScaleMajorInc)

 ChartScreenFactor = ChartScreenWidth / (ChartScaleMajorInc * X)

 ChartScreenZero = 1 + (0 - ChartScaleMin) * ChartScreenFactor

'draw header

 ForeColor = &H0&: j = -1

 HeaderHeight = 15

 Me.AutoRedraw = True

 Cls

 For n = 1 To ChartScreenWidth Step ChartScreenMajorInc

  Line (n, 1)-(n, HeaderHeight)

  j = j + 1:  CurrentX = n:  CurrentY = 2

  Print Trim(Str(Int(ChartScaleMin + ChartScaleMajorInc * j)))

 Next n

 Call ChartUpdate

End Sub

'LastBuf: last record number in file buffer array

'ScrolVal: number of vert divisions to scroll down

Public Sub ChartUpdate()

 Dim Graphindx As Long, CurrentTime As Date, n As Long, k As Integer, d As Integer, j As Long, t1 As Double, t2 As Double

 Dim ScrolVal As Integer

 Dim Pen As Integer

 'On Error GoTo esub

 On Error Resume Next

  ForeColor = &HFFFF80         ' Set foreground color.

 ScaleMode = 3   ' Set ScaleMode to pixels.

 DrawWidth = 1   ' Set DrawWidth.

 DrawStyle = 0

 Me.AutoRedraw = False

 Cls

'init variables

 ScrolVal = (Int(VScroll1.Value))

 For n = 0 To 15

  Pens(n, 0) = -500: Pens(n, 1) = -500

 Next n

 'DataGrid.List1.Clear

 For n = 1 To DataGrid.DataFlexGrid.Rows - 1

  DataGrid.DataFlexGrid.RemoveItem (0)

 Next n

 

'draw markers

  If Abs(yPos1 - yPos2) < 5 Then

   ForeColor = vbRed: DrawWidth = 2: yPos2 = yPos1

  End If

  Line (1, yPos1)-(ScaleWidth, yPos2), , B

 DrawWidth = 1: ForeColor = &HFFFF80

'vert grid

  DrawWidth = 1: ForeColor = &HFFFF80

  For n = HeaderHeight To ScaleHeight Step gsy

   If n > yPos1 + 2 Or n < yPos1 - 2 Then

    Line (1, n)-(ChartScreenWidth, n)

    Else

   End If

  Next n

'horiz grid

 For n = 1 To ChartScreenWidth Step ChartScreenMajorInc

  DrawStyle = 2:  DrawWidth = 1

  For k = 1 To (ChartScaleMajorInc / ChartScaleMinorInc)

   Line (n + k * ChartScreenMinorInc, HeaderHeight)-(n + k * ChartScreenMinorInc, ScaleHeight)

  Next k

  DrawStyle = 0:  DrawWidth = 2

  Line (n, HeaderHeight)-(n, ScaleHeight)

  CurrentX = n

  CurrentY = 5

 Next n

 n = 0

'draw time

 ForeColor = &HC0C000

 Do While n < UBound(DispData)

  If n > UBound(DispData) Then n = 0

   If Minute(DispData(n).RecTime) / 10 = Int(Minute(DispData(n).RecTime) / 10) Then

    If Hour(DispData(n).RecTime) + Minute(DispData(n).RecTime) <> d Then 'where d= last known hour and minute stamp

     d = Hour(DispData(n).RecTime) + Minute(DispData(n).RecTime)

     tStamp = Right("0" + Trim(Str(Hour(DispData(n).RecTime))), 2) + ":" + Right("0" + Trim(Str(Minute(DispData(n).RecTime))), 2)

     CurrentX = ScaleWidth / 2: CurrentY = ((DispData(n).Indx - ScrolVal) * gsy) + HeaderHeight

     Vcr1.Print tStamp

    End If

   End If

   n = n + 1

   If CurrentY > ScaleHeight Then Exit Do

 Loop

'draw graphs

 DrawWidth = 1: n = 0

 Do While n < UBound(DispData)

  Select Case DispData(n).ChannelID

   Case 1 To 5   'draw pens GC

    Pen = DispData(n).ChannelID

    ForeColor = PenColor(Pen)

    Pens(Pen, 1) = Pens(Pen, 0): Pens(Pen, 0) = DispData(n).Value * ChartScreenFactor + ChartScreenZero

    If Pens(Pen, 1) <> -500 Then

     Line (Pens(Pen, 1), ((DispData(n).Indx - 1 - ScrolVal) * gsy) + HeaderHeight)-(Pens(Pen, 0), ((DispData(n).Indx - ScrolVal) * gsy) + HeaderHeight)

    End If

   Case 8   'draw pen CC

    Pen = DispData(n).ChannelID

    ForeColor = PenColor(Pen)

    Pens(Pen, 1) = Pens(Pen, 0): Pens(Pen, 0) = DispData(n).Value * 5 * ChartScreenFactor + ChartScreenZero

    If Pens(Pen, 1) <> -500 Then

     Line (Pens(Pen, 1), ((DispData(n).Indx - 1 - ScrolVal) * gsy) + HeaderHeight)-(Pens(Pen, 0), ((DispData(n).Indx - ScrolVal) * gsy) + HeaderHeight)

    End If

   Case 9    'draw pen TC

    Pen = DispData(n).ChannelID

    ForeColor = PenColor(Pen)

    Pens(Pen, 1) = Pens(Pen, 0): Pens(Pen, 0) = DispData(n).Value * 10 * ChartScreenFactor + ChartScreenZero

    If Pens(Pen, 1) <> -500 Then

     Line (Pens(Pen, 1), ((DispData(n).Indx - 1 - ScrolVal) * gsy) + HeaderHeight)-(Pens(Pen, 0), ((DispData(n).Indx - ScrolVal) * gsy) + HeaderHeight)

    End If

   Case 32  'draw depth markers

    ForeColor = QBColor(12): DrawWidth = 1

    CurrentX = ScaleWidth * 0.95 - 25

    CurrentY = ((DispData(n).Indx - ScrolVal) * gsy) + HeaderHeight

    Line (CurrentX, CurrentY)-(ScaleWidth, CurrentY)

    If DispData(n).depth / ChartDepthInc = Int(DispData(n).depth / ChartDepthInc) Then

     CurrentX = ScaleWidth * 0.95 - 50

     CurrentY = CurrentY - 6

     Print DispData(n).depth * -1  'draw depth label

    End If

  End Select

  n = n + 1

  If (DispData(n - 1).Indx - ScrolVal) * gsy > ScaleHeight Then Exit Do

 Loop

 

'draw lagged depths

 ForeColor = &H0        ' Set foreground color.

  n = 1: j = 0

  Do While j < UBound(DispData)

   j = j + 1

   If DispData(n).DepthLag / ChartTimeInc <= DispData(j).Indx And DispData(j).ChannelID = 32 Then Exit Do

  Loop

  If j >= UBound(DispData) Then GoTo esub

  Do While n < UBound(DispData)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

   t1 = DispData(j).RecTime

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

   If DispData(n).Indx + DispData(n).DepthLag / ChartTimeInc >= DispData(j).Indx Then Exit Do

   n = n + 1

  Loop

  CurrentY = ((DispData(n).Indx - ScrolVal) * gsy) + HeaderHeight

  Line (0, CurrentY)-(ScaleWidth * 0.02, CurrentY)

  If DispData(j).depth / ChartDepthInc = Int(DispData(j).depth / ChartDepthInc) Then

   CurrentX = ScaleWidth * 0.02

   Print DispData(j).depth

   DataGrid.DepthValue = Int(DispData(j).depth) * -1

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'   DataGrid.ROPValue = Trim(Str(Round((t1 - t2) * 1440 / ChartDepthInc, 2)))

   t1 = t2

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

   k = n

   Do While DispData(k).Indx = DispData(n).Indx

    k = k + 1

   Loop

   k = k - 1

   Do While DispData(k).Indx = DispData(n).Indx

    Select Case DispData(k).ChannelID

     Case 1 To 5

      DataGrid.GCValues(DispData(k).ChannelID) = Round(DispData(k).Value / 50, 2)

     Case 8

      DataGrid.CCValue = Round(DispData(k).Value * 5, 2)

      DataGrid.TCValue.Text = "-"

     Case 9

      DataGrid.TCValue = Round(DispData(n).Value * 10, 2)

      DataGrid.CCValue.Text = "-"

    End Select

    k = k - 1

   Loop

   Call DataGrid.AddToList 'send gas values to grid

  End If

 Do While n < UBound(DispData)

  Do While j < UBound(DispData)

   j = j + 1

   If DispData(j).ChannelID = 32 Then Exit Do

  Loop

  If j >= UBound(DispData) Then GoTo esub

  Do While n < UBound(DispData)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

   t2 = DispData(n).RecTime

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

   If DispData(n).Indx + DispData(n).DepthLag / ChartTimeInc >= DispData(j).Indx Then Exit Do

   n = n + 1

  Loop

  'Debug.Print n, DispData(n).DepthLag

  CurrentY = ((DispData(n).Indx - ScrolVal) * gsy) + HeaderHeight

  Line (0, CurrentY)-(ScaleWidth * 0.02, CurrentY)

  If DispData(j).depth / ChartDepthInc = Int(DispData(j).depth / ChartDepthInc) Then

   CurrentX = ScaleWidth * 0.02

   Print DispData(j).depth

   DataGrid.DepthValue = Int(DispData(j).depth) * -1

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'   DataGrid.ROPValue = Trim(Str(Round((t1 - t2) * 1440 / ChartDepthInc, 2)))

   t1 = t2

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

   k = n

   Do While DispData(k).Indx = DispData(n).Indx

    k = k + 1

   Loop

   k = k - 1

   Do While DispData(k).Indx = DispData(n).Indx

    Select Case DispData(k).ChannelID

     Case 1 To 5

      DataGrid.GCValues(DispData(k).ChannelID) = Round(DispData(k).Value / 50, 2)

     Case 8

      DataGrid.CCValue = Round(DispData(k).Value * 5, 2)

      DataGrid.TCValue.Text = "-"

     Case 9

      DataGrid.TCValue = Round(DispData(k).Value * 10, 2)

      DataGrid.CCValue.Text = "-"

    End Select

    k = k - 1

   Loop

   Call DataGrid.AddToList 'send gas values to grid

  End If

  If CurrentY > ScaleHeight Then Exit Do

  n = n + 1

 Loop

esub:

 DataGrid.DataFlexGrid.RemoveItem (0)

 Me.AutoRedraw = True

 'SetFocus

End Sub
 

Public Sub FillDispArray(offset As Long)

 Dim k As Long, d As Long, dLag As Long, omitRec As Boolean

 Dim s As Long, n As Integer, Graphindx As Integer

 Dim IndexTime As Date

 Dim SVnow As Integer, SVwas As Integer

 On Error Resume Next

 ReDim DispData(2 ^ 16)

 CurrentTime = ChartData(offset - 1).RecTime

 CurrentDepth = ChartData(offset).depth '+ 1

 c1done = False: c2done = False

 IndexTime = CurrentTime

 k = 0: Graphindx = 1

' s = offset - 1

 s = 0

 For n = 0 To 15

  GraphPeaks(n, 0) = -5000

  GraphPeaks(n, 1) = -5000

 Next n
 

Do While s < offset And k < UBound(DispData) 'index display data

'Do While s > 0   'index display data
 

 IndexTime = ChartData(offset - s).RecTime

 Do While (IndexTime - ChartData(offset - s).RecTime) * 86400 < Vcr1.ChartTimeInc And s < offset 'collect records for each index
 

'FOR GC  'Check for SV change

  If (ChartData(offset - s).Mode = 0 Or ChartData(offset - s).Mode = 2) Then

   SVnow = 5

  ElseIf (ChartData(offset - s).Mode = 1 Or ChartData(offset - s).Mode = 3) Then

   SVnow = 10

  End If

  If SVnow <> SVwas Then 'new SVnow

   SVwas = SVnow

   If SVnow = 10 Then

    For t = 2 To 5

     GraphPeaks(t, 1) = GraphPeaks(t, 0): GraphPeaks(t, 0) = 0

    Next t

   Else

    GraphPeaks(1, 1) = GraphPeaks(1, 0): GraphPeaks(1, 0) = 0

   End If

  End If

   'store peaks if any

  If SVnow = 5 And ChartData(offset - s).ChannelID = 1 Then 'is methane

   If GraphPeaks(1, 0) < ChartData(offset - s).Value Then

    GraphPeaks(1, 0) = ChartData(offset - s).Value

   End If

  ElseIf ChartData(offset - s).ChannelID > 1 And ChartData(offset - s).ChannelID < 8 Then 'is component

   If GraphPeaks(ChartData(offset - s).ChannelID, 0) < ChartData(offset - s).Value And ChartData(offset - s).ChannelID > 1 Then

    GraphPeaks(ChartData(offset - s).ChannelID, 0) = ChartData(offset - s).Value

   End If

  End If

'FOR HW

  If ChartData(offset - s).ChannelID = 8 Then

   If GraphPeaks(8, 0) = -5000 Then GraphPeaks(8, 0) = 0: GraphPeaks(8, 1) = 0

   GraphPeaks(8, 0) = GraphPeaks(8, 0) + ChartData(offset - s).Value

   GraphPeaks(8, 1) = GraphPeaks(8, 1) + 1

  ElseIf ChartData(offset - s).ChannelID = 9 Then

   If GraphPeaks(9, 0) = -5000 Then GraphPeaks(9, 0) = 0: GraphPeaks(9, 1) = 0

   GraphPeaks(9, 0) = GraphPeaks(9, 0) + ChartData(offset - s).Value

   GraphPeaks(9, 1) = GraphPeaks(9, 1) + 1

  End If

'depth events

   Select Case ChartData(offset - s).ChannelID

    Case 64

     k = k + 1

     DispData(k).ChannelID = 64

     DispData(k).Indx = Graphindx

     DispData(k).RecTime = IndexTime

     DispData(k).Value = ChartData(offset - s).Value

     DispData(k).depth = ChartData(offset - s).Value

     DispData(k).DepthLag = ChartData(offset - s).DepthLag

     DispData(k).Mode = ChartData(offset - s).Mode

    Case 63

     CurrentDepthLag = ChartData(offset - s).Value

     k = k + 1

     DispData(k).ChannelID = 63

     DispData(k).Indx = Graphindx

     DispData(k).RecTime = IndexTime

     DispData(k).Value = ChartData(offset - s).Value

     DispData(k).depth = ChartData(offset - s).depth

     DispData(k).DepthLag = ChartData(offset - s).DepthLag

     DispData(k).Mode = ChartData(offset - s).Mode

    Case 32

     k = k + 1

     DispData(k).ChannelID = 32

     DispData(k).Indx = Graphindx

     DispData(k).RecTime = IndexTime

     DispData(k).Value = ChartData(offset - s).Value

     DispData(k).depth = ChartData(offset - s).depth

     DispData(k).DepthLag = ChartData(offset - s).DepthLag

     DispData(k).Mode = ChartData(offset - s).Mode

    Case Else

     omitRec = True

   End Select

  s = s + 1

 Loop

'load GC values to DispData

 For n = 1 To 5

  If GraphPeaks(n, 1) <> -5000 Then

   k = k + 1

   DispData(k).ChannelID = n

   DispData(k).Indx = Graphindx

   DispData(k).RecTime = IndexTime

   DispData(k).Value = GraphPeaks(n, 1) ' peak reading

   DispData(k).depth = CurrentDepth

   DispData(k).DepthLag = ChartData(offset - s).DepthLag

   DispData(k).Mode = ChartData(n).Mode

  'Debug.Print DispData(k).ChannelID, DispData(k).Value, DispData(k).Indx

  End If

 Next n

 'load GC values to DispData

 

 For n = 8 To 9

  If GraphPeaks(n, 1) <> -5000 Then

   k = k + 1

   DispData(k).ChannelID = n

   DispData(k).Indx = Graphindx

   DispData(k).RecTime = IndexTime

   DispData(k).Value = GraphPeaks(n, 0) / GraphPeaks(n, 1) 'average reading

   DispData(k).depth = CurrentDepth

   DispData(k).DepthLag = ChartData(offset - s).DepthLag

   GraphPeaks(n, 0) = -5000: GraphPeaks(n, 1) = -5000

  End If

 Next n

 

 IndexTime = ChartData(offset - s).RecTime

 Graphindx = Graphindx + 1

 'offset = offset - s

Loop

VScroll1.Max = Graphindx

 

Exit Sub

esub:

End Sub
 
 
 
 

Private Sub VScroll1_Change()

 Call ChartUpdate

End Sub

Private Sub DrawDispData(Begining As Integer, Ending As Integer, offset As Integer)

 Static charting As Integer
 

End Sub
 
 

Public Sub ReloadForm()

  Dim offset As Long

  If OMUX_Error = 0 And Connected = True Then

   Vcr1.RecordingOnOff.Enabled = True

   Vcr1.DisplayReal.Enabled = True

   Vcr1.CalMode.Enabled = True

  Else: OMUX_Error = 0

  End If

  

  PenColor(1) = vbBlack

  PenColor(2) = vbGreen

  PenColor(3) = &HC0C000     'vbCyan

  PenColor(4) = vbBlue

  PenColor(5) = vbMagenta

  PenColor(8) = vbRed

  PenColor(9) = &H80FF&  'vbYellow

  PenColor(10) = vbWhite

 

  

  ScaleMode = 3   ' Set ScaleMode to pixels.

  lastWindowState = -1

  ChartScaleMajorInc = 50

  ChartScaleMin = -50

  ChartScaleMax = 500

  ChartScaleMinorInc = 10

  ChartTimeInc = 30

  ChartDepthInc = 5

  offset = LastBuf

  Call FillDispArray(offset)

  Call DrawSheet

 DashBoard.Show 0, Vcr1

 DataGrid.Show 0, Vcr1

End Sub

Open in new window

0
 
LVL 14

Expert Comment

by:rachitkohli
ID: 21844045
The code you have provided is in-complete, lot of referenced objects are not available:
Where is RecData, what is it for
0
 

Author Comment

by:CKirby18
ID: 21845083
Thank you rachitkohli for your response.  I do realize that there are a lot of referenced objects not included in my latest post.  However, I simply posted it as a reference to my original post and how those two procedures were being called.

Here is the good news.  I had some free time this morning to actually take a look at what Idle_Mind had suggested.  After using the conversions that he gave me for Print and Line, it was actually quite simple for me to fix the first of my two posted solutions (I haven't looked at the second yet)!  I was expecting it to be much more complicated simply due to my lack of familiarity on that particular subject.  What is actually going to require the most time from me is finding an equivalent drawing style in .Net for the VB6 ones used in drawing the original graph.  However, I will probably use another post for that to see if anyone knows where to find a conversion list.

Thank you two for your feedback
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now