Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,571 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,930 people online right now. Registration is fast and FREE... Join Now!




can't connect to my com port

 
Reply to this topicStart new topic

can't connect to my com port, i get an error on me.comxmcomm1.portopen

daddyshaq
13 May, 2008 - 04:20 AM
Post #1

New D.I.C Head
*

Joined: 13 May, 2008
Posts: 4

vb

'DECLARATIONS
Option Explicit
Option Base 1

Private Sub cmdConfigureSheet_Click()
frmSetupSubgroupsAndCavities.Show
End Sub

Public Sub cmdStartStop_Click()
Dim cbr As CommandBar
Dim btn As CommandBarControl
Dim btn2 As CommandBarControl
Set cbr = Application.CommandBars("Standard")
'Set btn = cbr.Controls("Stop")
'Set btn2 = cbr.Controls("Go")


Dim strClearBuffer As String
Select Case Me.comXMComm1.PortOpen
Case False
If Not Sheet2.Range("ShowConfigDialog").Value Then frmSelectAndConfigureCommPort.Show
If frmSelectAndConfigureCommPort.Tag = True Then
With Me.comXMComm1
.CommPort = Sheet2.Range("WhichPort").Value
.Settings = frmSelectAndConfigureCommPort.cboRate.Value & ", " & _
Left(frmSelectAndConfigureCommPort.cboParity.Value, 1) & ", " & _
frmSelectAndConfigureCommPort.cboDataBits.Value & ", " & _
frmSelectAndConfigureCommPort.cboStopBits.Value
.PortOpen = True
.InputLen = 0
strClearBuffer = .InputData
End With
Me.cmdStartStop.Caption = "Stop collecting data from " & _
ThisWorkbook.BuiltinDocumentProperties("Subject").Value
ActiveSheet.Cells(2, 4).Activate
End If
'btn.Visible = True
'btn2.Visible = False
Case True
Me.comXMComm1.PortOpen = False
Me.cmdStartStop.Caption = "Begin collecting data from " & _
ThisWorkbook.BuiltinDocumentProperties("Subject").Value
'btn.Visible = False
' btn2.Visible = True
End Select

strReading = ""

Unload frmSelectAndConfigureCommPort

End Sub

Private Sub comXMComm1_OnComm()
On Error Resume Next
Dim strData As String
Dim strJunk As String
Dim lngCharCount As Long
CommHitter = CommHitter + 1
Debug.Print Me.comXMComm1.CommEvent, CommHitter
Select Case Me.comXMComm1.CommEvent
Case 2
' If Me.comXMComm1.InBufferCount >= 14 Then
lngCharCount = Me.comXMComm1.InBufferCount
With Me.comXMComm1
.InputLen = 1
strData = .InputData
' MsgBox strData & vbCrLf & vbCrLf & _
lngCharCount
Select Case Asc(strData)
Case 13, 10
strReading = Trim(RTrim(LTrim(CStr(strReading))))
If Not IsNumeric(strReading) Then _
strReading = Right(strReading, Len(strReading) - 1)
If Not IsNumeric(strReading) Then _
strReading = Left(strReading, Len(strReading) - 2)
ActiveCell.Value = strReading
' ActiveCell.Offset(0, 1).Value = Now
ActiveCell.Offset(1, 0).Activate
.InputLen = 0
strJunk = .InputData
strReading = ""
Case Else
strReading = strReading & strData
End Select
End With
' End If
End Select
End Sub


EDIT: Code blocks added => code.gif

This post has been edited by PsychoCoder: 13 May, 2008 - 04:37 AM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Can't Connect To My Com Port
13 May, 2008 - 04:39 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,997



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Are you receiving any errors, if so what are they? What is this code doing versus what you want/need it to do? These are vital pieces of information needed to help us help you. You cannot just post code and expect us to figure out what you want or what's going wrong smile.gif

You need to post a detailed message regarding the items above in order for us to be able to help. When you try and squeeze it into the description you lose most of it as it's a fixed length
User is offlineProfile CardPM
+Quote Post

daddyshaq
RE: Can't Connect To My Com Port
13 May, 2008 - 05:05 AM
Post #3

New D.I.C Head
*

Joined: 13 May, 2008
Posts: 4

QUOTE(PsychoCoder @ 13 May, 2008 - 05:39 AM) *

Are you receiving any errors, if so what are they? What is this code doing versus what you want/need it to do? These are vital pieces of information needed to help us help you. You cannot just post code and expect us to figure out what you want or what's going wrong smile.gif

You need to post a detailed message regarding the items above in order for us to be able to help. When you try and squeeze it into the description you lose most of it as it's a fixed length



the error i get is with the public sub cmdstartstop_click()

and me.comxmcomm1 is highlighted

this program hooks up to our quadra chek machine and it allows us to pull x and y cordinates into excel
User is offlineProfile CardPM
+Quote Post

daddyshaq
RE: Can't Connect To My Com Port
13 May, 2008 - 08:20 AM
Post #4

New D.I.C Head
*

Joined: 13 May, 2008
Posts: 4

QUOTE(daddyshaq @ 13 May, 2008 - 06:05 AM) *

QUOTE(PsychoCoder @ 13 May, 2008 - 05:39 AM) *

Are you receiving any errors, if so what are they? What is this code doing versus what you want/need it to do? These are vital pieces of information needed to help us help you. You cannot just post code and expect us to figure out what you want or what's going wrong smile.gif

You need to post a detailed message regarding the items above in order for us to be able to help. When you try and squeeze it into the description you lose most of it as it's a fixed length



the error i get is with the public sub cmdstartstop_click()

and me.comxmcomm1 is highlighted

this program hooks up to our quadra chek machine and it allows us to pull x and y cordinates into excel





this exact program is running on some win2k machines but will not run on this newly formatted winxp machine its an excel file that pulls data off of a qaudra chek machine which is connected through a serial port.
the excel file opens properly but when you click the button to start the data capture it errors out opening up the vb editor

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:56PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month