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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:31:26+00:00 2026-06-18T06:31:26+00:00

I’m new to Visual Basic 6, so please be patient (and thorough with your

  • 0

I’m new to Visual Basic 6, so please be patient (and thorough with your answers).

I’m building a form and I need to check if the information entered in one of its fields is numeric, otherwise the program has to beep.

The field is part of an array of controls and it is named txtMyField(0)

Last thing in my code I’ve written:

Private Sub txtMyField_Change(Index As Integer)
If Not IsNumeric(txtMyField(0).Text) Then
    Beep
End If
End Sub

I don’t know if this code is correct and I don’t how to call the Sub to use it in order to check the field’s value before inserting in database.

Thanks a lot for your help!

  • 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-18T06:31:27+00:00Added an answer on June 18, 2026 at 6:31 am

    You can do this by using the Validate event. You need to ensure that the CausesValidation property is true, if it is then the Validate event will be raised for that control.

    Your event might look something like this:

    Private Sub txtMyField_Validate(Index As Integer, Cancel As Boolean)
        If Not IsNumeric(txtMyField(Index).Text) Then
            Beep
            Cancel = True
        End If
    End Sub
    

    This would ensure that all the controls in your control array are numeric (given that their CausesValidation property is set to True at startup). If one of the controls is empty or contains non-numeric characters you will get a Beep when the control loses focus.

    Note some things here

    • Sounding a Beep is not really a good way to indicate a validation error. A messagebox or textbox in the form to display the error is usually a better way. The user may not hear your beep or may not understand that “a beep” means “you need to provide a number in this field”.
    • Your code referenced control with index = 0. The event may fire for any of the controls in the control array, so checking the value of control(0) is not really a logical thing to do when you should be validating control(5) (for example).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm brand new to Visual Basic and I need some help with a program
I am relatively new to Visual Basic. When it comes to logging, in Java
I am very new to Classic ASP and Visual Basic. I am having trouble
Im new to visual studio and C# - and one thing in VS drives
I'm using Visual Basic 2010 Express. I have a form that can be minimized.
I am a new visual basic learner and I already have some difficulties in
I am new to Visual Basic.NET and I am just playing around with it.
I'm rather new to visual basic and I'm making a text based game for
Im new to visual basic.. I would like to ask on how to fixed
I’m new to visual basic.net . I have experience in C++ programming, but never

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.