Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8792643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:00:31+00:00 2026-06-13T23:00:31+00:00

Good Day I’m trying to send data to a comport COM1. A generic printer

  • 0

Good Day

I’m trying to send data to a comport “COM1”. A generic printer driver is set up on comport “COM1”. When sending data to this port I receive a run-time error ‘8015: Could not set comm state, there maybe one or more invalid communications parameters’. After clicking ok to that error message i get another error, run-time error ‘8018: Operation valid only when the port is open’. I believe this issue can be resolve because in Command Prompt I can copy a text file to the port with the command “copy C:\textfile.txt COM1” and it works without any issues. That’s my situation.

The methods I have tried are as follow:

  • Using the MSComm control (which produces the errors above)
  • Using windows API call (which gave a different error ‘Invalid Functions’)
    API Link: http://www.thescarms.com/vbasic/CommIO.aspx
  • Using the shell function to shell cmd.exe with the ‘copy’ command (this method works
    when it wants to)
  • Using VB6e FileCopy() function that doesn’t work when copying to ports

I believe the person that can answer this question is someone that knows in depth information about COM Port communication and knows in depth information about windows copy command.

I read on some forum (I’ve been through too many) that if you remove the plug and plug it in back that it resolve this issue. I haven’t tried that yet but i have tried turning off the device and putting it on back which I believe is the same thing.

If anyone can help with this issue it would be very much appreciated

Here is a link that might be interesting:

  • http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx

Thanks,

Jorgen

As requested by Beaner:

Here is the snippet of code that I’m using.

Private Sub Initialize_COMPort()

On Error GoTo COMPort_Error

    If MSComm1.PortOpen Then
        MsgBox "Port is opened"
        MSComm1.PortOpen = False
    End If

    MSComm1.Settings = "9600,n,8,1"
    MSComm1.CommPort = Val(CbCOMPorts.ListIndex) + 1
    MSComm1.PortOpen = True
    MSComm1.RThreshold = 1
    MSComm1.Handshaking = comXOnXoff

    Exit Sub

COMPort_Error:
    MsgBox Err.Number & " - " & Err.Description, vbCritical + vbOKOnly, "Port Tester", Err.HelpFile, Err.HelpContext
End Sub

The error occurs when:

MSComm1.PortOpen = True

is executed.

@Hrqls I appreciate the code however the code you gave me is similar to mind and when executed it the error still persist. The error occurs at the same statement

.PortOpen = True

@Hrqls I haven’t try using the printer control before however this device is not actually a text printer it is a card embosser. Its the “Matica Z3i AF” embosser the program I’m currently working on will be used to emboss cards.

The method currently in place is to use the embosser is a batch file that basically runs a ‘copy’ command of a text file with the card info to the print in a format that the embosser understands.

I shall try using the printer control until then thanks for the responses and I shall keep everyone up to date if the problem is resolved.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:00:32+00:00Added an answer on June 13, 2026 at 11:00 pm

    I assume the error comes from the fact that COM1 is already in use by the printer, in that case your MSCOMM control cant use COM1 as well

    What do you want to print ?

    The easiest, and most straightforward to print something is to use the Printer object

    For example to print the current time :

    Private Sub Command1_Click()
      Printer.Print CStr(Now)
      Printer.EndDoc
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Day, Can someone confirm what was said at the bottom of this post
Good day, all. I know that this is a pretty basic question in terms
Good day, Stack Overflow. I have a homework assignment that I'm working on this
Good Day, I have a PL-SQL query as follows. I'm trying to execute a
Good day. I'd like to ask a question. Why TextBox control Txt in this
Good day. I'm trying to filter logs with get-winevent. When I working with local
Good day! I want to show all the pictures in the folder, but this
Good day! I've a model that is binded from JSON request, say like this:
Good day everyone. I'm trying to figure out a way to use multiple flags
Good day, I am having an issue trying to get the Text on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.