Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Converting visual basic 6 to visual basic 2005



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> Visual Basic Forum
View previous topic :: View next topic  
Author Message
hibernate89



Joined: 29 Jun 2008
Posts: 4

PostPosted: Fri Jul 04, 2008 7:26 am    Post subject: Converting visual basic 6 to visual basic 2005 Reply with quote

Hi,
I want to convert this viusal basic 6 to VB 2005 coding.

Dim a, b, c, d, e, f, g, h, i, j, x, y, Num1, Num2, Num3, Num4, Num5 As Integer
Dim l, k, m, n, o As Single
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oRng As Excel.Range
Dim oSheet As Excel.Worksheet
Dim outbuff() As Byte
Dim MatLab As Object
Option Explicit

Private Sub Btn1_Click()
Rx.text = ""
Sn1.text = ""
Sn2.text = ""
Sn3.text = ""
Sn4.text = ""
Sn5.text = ""
End Sub
Private Sub btn2_Click()
Dim Result As String

Set MatLab = CreateObject("Matlab.Application")

MatLab.Visible = True

Result = MatLab.Execute("cd D:\student\tinaMATLAB")
Result = MatLab.Execute("Test2GUI")
End Sub

Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeBinary
MSComm1.RThreshold = 1
MSComm1.PortOpen = True

'Declare the variables to be 2 so that when the values are store into the excel cells, it will start to store in row 2 onwards.
a = 2
b = 2
c = 2
d = 2
e = 2
f = 2
g = 2
h = 2
x = 2
y = 2

' Start Excel and get Application object.
Set oXL = CreateObject("Excel.Application")
oXL.Visible = True

' Get a new workbook
Set oWB = oXL.Workbooks.Add
Set oSheet = oWB.ActiveSheet

' Add table headers going cell by cell.

oSheet.Cells(1, 1).Value = "LM35"
oSheet.Cells(1, 2).Value = "HIH"
oSheet.Cells(1, 3).Value = "TGS825"
oSheet.Cells(1, 4).Value = "TGS2600"
oSheet.Cells(1, 5).Value = "TGS826"
oSheet.Cells(1, 7).Value = "T(degreeC)"
oSheet.Cells(1, Cool.Value = "RH(%)"
oSheet.Cells(1, 9).Value = "TGS825(uS)"
oSheet.Cells(1, 10).Value = "TGS2600(uS)"
oSheet.Cells(1, 11).Value = "TGS826(uS)"

' Format A1:D1 as bold, vertical alighnment = center.
With oSheet.Range("A1", "K1")
.Font.Bold = True
.VerticalAlignment = xlVAlignCenter
End With

' Autofit columns AVery Happy.
Set oRng = oSheet.Range("A1", "K1")
oRng.EntireColumn.AutoFit

' Make sure Excel is visible and give the user control of Microsoft Excel's Lifetime.
oXL.Visible = True
oXL.UserControl = True

Exit Sub

Err_Handler:
MsgBox Err.Description, vbCritical, "Error:" & Err.Number
End Sub


Private Sub Form_Unload(Cancel As Integer)
' Make sure you release object references.
Set oRng = Nothing
Set oSheet = Nothing
Set oWB = Nothing
Set oXL = Nothing
End Sub

Private Sub MSComm1_OnComm()
Dim buffer() As Byte
Dim text As String
Dim AddPos_1 As Integer

Select Case MSComm1.CommEvent
Case comBreak
MsgBox ("Break received")
Case comEventFrame ' Framing Error
MsgBox ("comEventFrame Reveived")
Case comEventOverrun ' Data Lost.
MsgBox ("comEventOverrun Reveived")
Case comEventRxOver ' Receive buffer overflow.
MsgBox ("comEventRxOver Reveived")
Case comEventRxParity ' Parity Error.
MsgBox ("comEventRxParity Reveived")
Case comEventTxFull ' Transmit buffer full.
MsgBox ("comEventTxFull Reveived")
Case comEventDCB ' Unexpected error retrieving DCB]
MsgBox ("comEventDCB Reveived")
' Events
Case comEvCD ' Change in the CD line.
MsgBox ("comEvCD Reveived")
Case comEvCTS ' Change in the CTS line.
MsgBox ("comEvCTS Reveived")
Case comEvDSR ' Change in the DSR line.
MsgBox ("comEvDSR Reveived")
Case comEvRing ' Change in the Ring Indicator.
MsgBox ("comEVRing Reveived")
Case comEvReceive
On Error Resume Next
'MsgBox ("comEVReceive Reveived")
j = MSComm1.InBufferCount

'Debug.Print j
buffer = MSComm1.Input
For i = 0 To j
Rx.SelStart = Len(Rx.text)

text = Hex$(buffer(i)) '& text

If Len(text) = 1 Then
text = "0" & text
End If
'
Rx.SelText = text

Next i

Rx.SelStart = Len(Rx.text)

AddPos_1 = InStr(Int(Rx.SelStart) - 153, Rx.text, "000CC")

If AddPos_1 > 0 Then
Sn1.text = Mid(Rx.text, AddPos_1 + 9, 4)
Num1 = CInt("&H" & Sn1.text)
Sn1.text = (Num1 * 5) / 1023
m = Sn1.text
oSheet.Cells(x, 1).Value = m
x = x + 1

oSheet.Cells(d, 7).Value = (m / 10) + 25
d = d + 1

Sn2.text = Mid(Rx.text, AddPos_1 + 13, 4)
Num2 = CInt("&H" & Sn2.text)
Sn2.text = (Num2 * 5) / 1023
n = Sn2.text
oSheet.Cells(y, 2).Value = n
y = y + 1

oSheet.Cells(e, Cool.Value = ((n / 5 - 0.16) / 0.0062) / (1.0546 - 0.00216 * m)
e = e + 1

End If

AddPos_1 = InStr(Int(Rx.SelStart) - 153, Rx.text, "000BB")

If AddPos_1 > 0 Then
Sn3.text = Mid(Rx.text, AddPos_1 + 9, 4)
Num3 = CInt("&H" & Sn3.text)
Sn3.text = (Num3 * 5) / 1023
l = Sn3.text

oSheet.Cells(a, 3).Value = l
a = a + 1


oSheet.Cells(f, 9).Value = 1 / ((10 / l - 1) * 10) * 1000


f = f + 1

Sn4.text = Mid(Rx.text, AddPos_1 + 13, 4)
Num4 = CInt("&H" & Sn4.text)
Sn4.text = (Num4 * 5) / 1023
o = Sn4.text
oSheet.Cells(b, 4).Value = o
b = b + 1

oSheet.Cells(g, 10).Value = 1 / ((50 / o) - 10) * 1000
g = g + 1
End If


AddPos_1 = InStr(Int(Rx.SelStart) - 153, Rx.text, "000AA")

If AddPos_1 > 0 Then
Sn5.text = Mid(Rx.text, AddPos_1 + 9, 4)
Num5 = CInt("&H" & Sn5.text)
Sn5.text = (Num5 * 5) / 1023
k = Sn5.text


oSheet.Cells(c, 5).Value = k
c = c + 1

oSheet.Cells(h, 11).Value = 1 / ((5 / k - 1) * 33) * 1000
h = h + 1
End If


Rx.text = Rx.text & vbCrLf

End Select
End Sub

Private Sub save_Click()
oXL.SaveWorkspace
End Sub
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> Visual Basic Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap