Advertisement

06.22.2008 at 11:37AM PDT, ID: 23505981
[x]
Attachment Details

Convert VB6 "Drawing" code to VB.Net

Asked by CKirby18 in Visual Studio, Miscellaneous Programming, Microsoft Visual Basic.Net

Tags:

I need to convert the following VB6 code in VB.Net.   Can someone please help meStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
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
[+][-]06.22.2008 at 12:30PM PDT, ID: 21841890

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio, Miscellaneous Programming, Microsoft Visual Basic.Net
Tags: Visual Basic
Sign Up Now!
Solution Provided By: Idle_Mind
Participating Experts: 2
Solution Grade: B
 
 
[+][-]06.22.2008 at 02:18PM PDT, ID: 21842254

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.22.2008 at 02:53PM PDT, ID: 21842351

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.23.2008 at 12:06AM PDT, ID: 21844045

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.23.2008 at 04:29AM PDT, ID: 21845083

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628