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 9266477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:19:41+00:00 2026-06-18T14:19:41+00:00

I’m currently trying to code a program that interfaces with USB devices based on

  • 0

I’m currently trying to code a program that interfaces with USB devices based on their serial number. I have it partially working such that it will accept proper serial numbers in the textbox but if anything but an integer is put into the box it will throw and error. How can I fix this? So far I’ve been unsuccessful in trying to work around this. In a nutshell, I want the program to read the 5 digit serial from the textbox and try to connect, and if anything other than an integer is added, it’ll simply throw a message to the user saying the serial isn’t correct. Here’s what I have so far.

'Declares an integer to be used for custom serial numbers incase phidgets need to be swapped.
    Dim MC1Serial As Integer
    'Throws error if there's no real serial in the corresponding box.
    If TextSerial1.Text = 0 Then
        MsgBox("Please ensure you have a proper serial numbers in the textbox, and not 0")
    Else
        MC1Serial = TextSerial1.Text
    End If
    'Creates a new instance of a MC for the first controller.
    MC1 = New Phidget21COM.PhidgetMotorControl
    'Attempts to attach phidget and either checks the box or throws an error.
    MC1.Open(MC1Serial)
    MC1.WaitForAttachment(1000)
    If MC1.IsAttached = True Then
        CheckMC1.Checked = True
        'Enables the timer to allow the position of the buttons to update accordingly.
        TimerJoysticks.Enabled = True
    Else
        MsgBox("There was a problem finding MC1. Check connections and settings.")
    End If
  • 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-18T14:19:42+00:00Added an answer on June 18, 2026 at 2:19 pm

    There are many things you can do. Val Function is one of them. You can also use IsNumeric to check wether the whole input string is actually a number.

    If Not IsNumeric(TextSerial1.Text) or Val(TextSerial1.Text) = 0 Then
        MsgBox("Please ensure you have a proper serial numbers in the textbox, and not 0")
        ' You should exit the sub here so that the code doesn't continue.
    
    Else
        MC1Serial = CInt(TextSerial1.Text)
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.