Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Because APSDPS.Text is a String and you can't use strings in numeric calculations. CDbl converts a string to a double (or raises an exception if the string cannot be converted). For example, you can't execute

x = 5.3 + "19.12"

but you can do

x = 5.3 + Cdbl("19.12")
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You have to convert it to a number before you use it in the calculation. Typically, this is done by first checking to see if the string CAN be converted to a number as in

If IsNumeric(APSDPS.Text) Then
    APSDPS3.text = (CDbl(APSDPS.Text) * (1.0 + 15.0/100.0)).ToString
fRodzet commented: Useful +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

How do you define when you are finished your input? Event based programming relies on triggers to do anything. In your case the trigger is end-of-input. But you have to define what that is.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

First of all, I would use StringBuilder instead of String if you are doing a lot of concatenating (initialize the StringBuilder object to be large to avoid multiple reallocations). Strings have to be reallocated every time you concatenate. StringBuilder objects do not.

Next, I would concatenate "," plus the new string value, then at the end I would do a SubString to remove the first ",". You won't know the length of your string until you are out of the loop but why are you concerned about 255 characters?

If you declare the StringBuilder as

Dim sb As New System.Text.StringBuilder(10000)

then the initial max size of sb is 10000 chars. It will increase automatically if that limit is reached. You can get the length by

sb.Length
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'll have a look at the SQLConn format in a bit but in ADO.net you fetch the records and step through them as follows

Imports ADODB

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Dim con As New Connection
        Dim rec As New Recordset

        con.Open("Driver={SQL Server};Server=.\SQLEXPRESS;Database=mydb;Trusted_Connection=yes;")
        rec.Open("select uname from test2", con, CursorTypeEnum.adOpenStatic)

        Do Until rec.EOF
            Debug.WriteLine(rec("uname").Value)
            rec.MoveNext()
        Loop

        rec.Close()
        con.Close()

    End Sub

End Class
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You might want to have a look at Kill-a-Watt

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In order to prevent errors on ' all you have to do is replace each ' with two '. Instead of using

name

use

name.Replace("'","''")

If you do that SQL won't complain.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Because the code in the Finally is always executed you might wonder what's the point. The point is that the code in the Finally block is logically associated with the code in the Try and Catch blocks. If you saw

Try
    'some statements
Catch ex As Exception
    'some more statements
End Try

'some other statements

You might (at some point) either be tempted to insert more code after the End Try, or move the code after the End Try somewhere else. However, if you saw

Try
    'some statements
Catch ex As Exception
    'some more statements
Finally
    'some other statements
End Try

you would know immediately that "some other statements" is associated with "some statements" and "some more statements". Typically, the Finally block contains cleanup code. For example, if, in the Try block, you opened one or more files, you'd want to close those files whether or not an exception occurs. Rather than duplicate this code in the Try and Catch blocks, you place it in the Finally block.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@pritaeas - not a hacking movie but have you seen "The Man From Earth"?

pritaeas commented: Thanks for that one, top notch! +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

One thing you can do is to display a message to the user stating that some email systems with aggressive spam filters may block the receipt of your email. You could warn them to either whitelist your address or check the spam box.

Alternately, you could send two messages. One would be the receipt and the other could be a generic (no suspicious keywords or phrases) saying that a receipt has been sent and if it is not received in a specified time frame that it was likely blocked by a spam filter. That email should contain an address to reply to if the receipt was not received.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Problems:

  1. No comments
  2. No description of any kind as to what you want to do
  3. Incomplete error message
  4. No posting of the value of sampque
daniel955 commented: Yup +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I prefer option 2. Most of the comments I've seen consist of one-liners and most posts do not have comments so it's not like the comments will overwhelm the other content. It's not an issue at home where my internet connection is fast and reliable but here at the cottage, clicking on "show comments", when there are no actual comments, can waste significant time.

And the fact that option 2 is easier to implement is a nice bonus (for you) ;-)

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I wouldn't be surprised to be told that cigarette companies are paying for product placement. I'm sure they were absolutely thrilled when Mad Men became such a big hit.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I have found that for smaller files, it is easier to let the system read all the lines instead of bothering with streams and such.

Dim row As Integer = 0

For Each line As String In System.IO.File.ReadAllLines(MAPFILE)

    Dim flds() As String = line.Split(","c)

    For col As Integer = 0 To UBound(flds)
        MapString(row, col) = flds(col)
    Next

    row += 1

Next

That way you don't have to worry about opening, closing and testing for end of stream.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you don't mind spending a few $$ on a good book I recommend Mastering Microsoft Visual Basic 2010 by Evangelos Petroutsos (Sybex). If you just want to get your feet wet for free you can work through the video series here

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can't replace the current form because it is the topmost window and closing it will close the application. But what you could do is make the main form invisible until it is needed again.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Audacity is free and open source, and it is available on multiple platorms. You do not need a video converter for mp3 files. You can load the file into Audacity and export each section as a separate mp3 file. I suggest you make a copy of your original file and play with the copy. It's easy to make an irreversible mistake when getting used to an unfamiliar application.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Congratulations on your day of celebration. I hope your country achieves a future of peace. My condolances on the loss of your brother.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That's a good assignment. I imagine you'll learn something by doing it.

Maligui commented: +1 Good reply! +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In the non-working code you display the total (line 315) from _strTotalCost, however, aside from initializing this string in line 22 you never actually copied the numeric total into the string so it was only ever going to display the string set at line 22. At that point _decTotalCost has the value 0.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The regular expression for globe telecom numbers would be

"091[5|6|7]\d{7}"

091 followed by 5, 6 or 7, followed by seven digits. And to use the regular expression you include

Imports System.Text.RegularExpressions

Then to do the test

Dim pattern As String = "091[5|6|7]\d{7}"

If Regex.IsMatch(txtPhoneNumber.Text,pattern) Then
    'phone # is OK
Else
    'bad format
End If
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Dim lines() As String = System.IO.File.ReadAllLines(myfile)

For Each line As String In Filter(lines,IdBox.Text)
    Dim fields() As String = line.Split(vbTab)
    MsgBox(fields(1) & " " & fields(2))
Next

Filter returns all lines containing the given text.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Why don't you start by telling us the structure of your tables, and the nature of the information you want to extract from them. If you can do that in English (instead of code), perhaps we can build a query that will get that data directly from the tables without all the messy bits of code.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Declare a variable with Class scope and save a reference to the textbox in that variable. The proper way to create the control is as follows:

mytextbox = New TextBox()
mytextbox.Location = New Point(130,y)
Me.Controls.Add(mytextbox)

Then to get the entered text just use

text = mytextbox.Text
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

For every keystroke. Add this event handler and you will see. The titlebar will be updated every time you press a key.

Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
    Me.Text = TextBox1.Text
End Sub
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Very inefficient way to test for odd or even. A better way is

(number And 1) = 0

This evaluates to True if number is even and False if it is odd.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

How elaborate do you want to get. A very simple solution is Stickies. This is a replacement for the Windows sticky-notes app. It supports alarms (you can put a sticky to sleep, visibly or invisibly) and have it alarm on a given date/time. Or you can leave a to-do sticky on your desktop (you can collapse it into the title bar or leave it open). It's also free. I've been using it for years.

If you have Microsoft Office, Outlook has a very good calendar with task lists, to-do lists, reminders, etc. If you use ThunderBird for email then there is a calendar plugin that works well (so I've been told).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Tubular Bells (original) followed by Chopin's Ballade in G Minor (piano).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My two cents - you try to open the database (lines 14-22) but you continue on and try the query even if the database doesn't open. If the open fails then you should not try the query.

Begginnerdev commented: Yeah, but what does a yellow light mean? +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I am expecting either no response, or YES, YES and YES. If the latter then I want to stay focused on the justification and get responses to statements from the Qur'an that are either scientifically wrong, contradictory, or completely opposed to the statement.

It doesn't matter if the Qur'an contains accurate statements. If the Qur'an is supposed to be the infallible word of Allah then any blatantly false statement that proves it is fallible shoud settle that discussion. It won't, obviously. But in science (and logic) finding a single case that invalidates the hypothesis is sufficient and the OP wanted (based on the thread title) to argue logic.

I am tired of the faithful telling me that I am wrong for not believing. I am tired of people crying "media bias" for reporting the facts. I do not limit myself to the religious faithful. I also oppose blind faith in political or economic ideology as well as blind faith in junk science such as homeopathy. Basically any belief without thought.

mike_2000_17 commented: Bang on! +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can simplify the loops by using

For Each phCheck As CheckBox In Me.Controls.OfType(Of CheckBox)()

That will iterate through only CheckBox controls.

iFrolox commented: Thanks for trying :) it have me same result as my code :P +2
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That's what Christians do when we ridicule their religion or religious figures

It's not my intention to ridicule anyone's religious beliefs, Christian, Muslim or otherwise (except perhaps for snake-tossers and creationists who believe dinosaurs and man coexisted). However, when blatantly false statements are made then I feel obliged to respond.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Wasn't this already asked and answered here?

Begginnerdev commented: Good catch, Iggy. +5
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

For a clarification of the usage of "everyone", I'm going to define that as "an over-whelming majority"

That's only because the over-whelming majority was told by their president, a man who, under a non-currupt system should be trusted, that Iraq had weapons of mass destruction. Your vice-president had strong ties to a company that stood to make untold billions as long as Americans could be duped into invading a country that posed no threat to the United States. Bush claimed that "God" told him to invade Iraq. It wasn't God, It was Chaney and Haliburton and the arms manufacturers.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I already said I thought they should be banned.

You are far more likely to die from a gun in states with the laxest gun control laws.

20 Deadliest Gun States

My older son completed his PhD at Arizona State University just as the state legislature was considering allowing people to carry concealed weapons on University property. Can you tell me how, in a sane country, this can be justified? And if that can be justified, why should it not be legal for anyone to carry weapons into, say, a courtroom? According to the standard rhetoric, courtrooms would be a lot safer if everyone were pasking heat. Where does one draw the line?

You have a party (Republican) that responds to any measures attempted by the Democrats to improve your lives, with flag waving and rhetoric (and out and out lies) that your freedoms are being stripped away even though they (Republicans) were responsible for things like the Partiot Act and designated free speech zones. That is a corrupt system. I do not believe that here in Canada we are immune to the same problems. A previous Liberal government spent billions setting up a national long gun registry. This was several magnitudes greater than necessary (in Manitoba we built a state of the art control centre with state of the art computer systems to control our provincial energy grid for 64 million dollars). Our current Conservative government is determined not only to scrap the registry but …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

According to New York Mayor, Mayor Michael Bloomberg:

You know, to arm everybody and have the Wild West all the time is one of the more nonsensical things you can say, ... It just does not make any sense. The bottom line is if we had fewer guns, we would have a lot fewer murders. ... Do you really think that you’d be safe if anyone in the audience could pull out a gun and start shooting? I don’t think so.

New York has the strictest gun control legislation in the country and is one of the safest states in which to live.

Question - do you feel it was appropriate for the shooter to amass the weapons and ammunition that he carried into the theatre?

Question - what is the justification for owning an assault rifle capable of firing 5-60 rounds per minute?

Question - why is it that buying two packages of Sudefed at a time is enough to get you on a watch list but6000 rounds of ammo is not?

Every year there are 30,000 gun deaths. That amounts to ten 911-scale tragedies every year. When foreigners kill 3000 Americans, the country (and quite rightly) reacts strongly. Apparently, though, it's quite alright if Americans kill ten times that many Americans every year. There are the expressions of outrage and sympathy for a week or two and then it's business as usual until the next killing spree.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What system do you mean? Who says its corrupt?

A system that sees nothing wrong with carrying concealed weapons in a church. A system that can't even pass a law that restricts handgun sales to only three per month. A system that allows someone to purchase 6000 rounds of ammunition and a one hundred shot clip (drum) with no warning flags. A system that says even if you have several emails from someone stating their intention to "shoot-em-up" the authorities cannot prevent that person from legally obtaining a weapon. A system that refers to the systematic sexual assault of young boys over a 15 year period as a "sex scandal" instead of what it really is (rape). A system that allows more gun dealers than gas stations and ten times as many gun dealers as there are McDonalds. A system that (as of ten years ago) was still putting three million guns per year into circulation.

A lot of Americans are broke, or angry, or paranoid, or all three, and a lot of these people are heavily armed. It’s not exactly a shock that this combination of factors helps produce 15,000 murders per year.

And getting back to the 100-shot clip - I understand that if it hadn't jammed, there could easily have been dozens more dead. Of course you will respond, "if everone else in the theatre had been armed someone would have shot him before so many were killed or injured". You are retired so I'm …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

So how is the media going to spin this so that all the issues will be discussed except the one that really matters? What hoops are the politicians going to jump through so that they can appear to be doing something but actually leave things exactly as they are now? I see that Bloomburg is calling on the president to take steps, although he has avoided actually suggesting what steps might be appropriate. The only people who are making suggestions are those people who do not rely on votes. Obama and Romney have been quick to offer their sympathies but little else.

The media has been quick to label the shooter as possibly schizophrenic. Blame a medical condition rather than a corrupt system. If the shooter is schizo then no one is to blame. The authorities have labeled him a lone-wolf terrorist. Naturally, if they label him a terrorist then the obvious response is to throw more money into the "war against terrorism" rather than to address the core issues.

They have labeleled the shooter a terrorist. I think, instead, he should be considered a canary; just like the ones they supposedly used in coal mines years ago. I think we're seeing the tip of the iceberg. As more and more people see the American Dream washed away by a torrent of debt; when people, especially those with college degrees (bought with loans which they will likely never pay off) realize that the only jobs in their future are McJobs, …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Your original post was ambiguous. You said you had a tab delimited file which means one complete record per line with the individual fields separated by a tab character. The form you gave an example of is not tab delimited. I based my answer on option one because I am a programmer and therefore lazy. If your data is in the second form then you sorta do it the same way. If the file contains only one set of data then you can use the following (which will work no matter what order the data is in)

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Dim record As New Dictionary(Of String, String)

        For Each line As String In System.IO.File.ReadAllLines("d:\temp\test.txt")
            Dim fields() As String = line.Split(":")
            record.Add(Trim(fields(0)), Trim(fields(1)))
        Next

        TextBox1.Text = record("Forename")
        TextBox2.Text = record("Surname")
        TextBox3.Text = record("Employee Number")

    End Sub

End Class

If you have multiple employees in the file then you can create nested dictionaries where the outer dictionary is a

Dim Employees As New Dictionary(Of String, Dictionary(Of String,String))

The key would be something unique such as the Employee Number.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The answer is "it depends". It depends on the type of database (Access, SQL, mySQL, etc), and it depends on the actual data in the field. You can use wildcards in SQL queries such that if your query looks like

select * from myTable where MovieName like 'Rocky%'

then the returned records will be Rocky, Rocky II, etc. If you only want movies with VI (but not VII, etc) then the query

select * from myTable where MovieName like '% VI'

Note that you need the blank after '%' so that you don't match (for example) 'Halloween XVI'

kkhembrom commented: Thank you Sir.. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Sometimes sorting data can be easy and sometimes it can be difficult. If you have data in a listview you can spend a great deal of time writing ICompare functions. This is appropriate for non-trivial applications but can be a little intimidating for inexperienced programmers. Also, it is a problem where the format of the input data changes. Detached recordsets provide a method which allows ad hoc sorting of data. With a little planning, they can be used to provide sorting for data where the number of fields is not known until runtime. Once you get the "messy" stuff out of the way (defining the fields), the actual operation is relatively simple. Also, sorting of columns with multiple criteria is trivial. Another benefit is that sorting can be done without having to write custom sort code. The following code requires a form with three buttons (named btnByName, btnByDate and btnBySalary), and one ListView (named ListView1). ListView1 should be set to Details view and have three columns with the header text "Name", "Date", and "Salary".

Sorting of the data in the recordset is done by assigning a string to the Sort property. Sorts can be in ascending (ASC) or descending (DESC) order. A separate order can be given for each field. You give the sort string as follows

recordset.Sort = "fldname direction, fldname direction, etc"

You can specify one field or multiple fields. The default sort order is ASC so the following

recordset.Sort = "fldname, fldname DESC"
Begginnerdev commented: Good tutorial +5
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Use & instead of + to concatenate strings

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I think it would be less confusing and more consistent to use "Reverend Jim" in both cases.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My.Application.CommandLineArgs

returns an array of strings, one string per argument

Pride commented: Good +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@Hani

First you're speaking about what you obviously don't seem to know.

Ad hominem attack - if you can't dispute the facts then attack the person.

Many principles in Islam do not apply at all to other religions.

Can you state a few of these principles so that they can be addressed?

I'm only showing you the facts about Islam that Muslim scholars know and teach.

No. You are stating an opinion and that opinion is not backed by the facts. As lawyers say, res ipsa loquitur. The Qur'an speaks for itself. @Mike has referenced verses in the Qur'an that incite violence against non-believers. I suspect you did not respond to that because no response is possible.

It does not matter what Muslim scholars teach. What is under dispute is the basis for your beliefs. If a mathematician teaches that the value of pi is 3.0 that does not make it so. If all mathematicians teach the same thing it still does not make it so.

When I was in elementary school, each day began with a reading from the Old Testament. It was only after I grew older and read that hate and violence filled book for myself that I found out that the daily readings were carefully picked so as not to frighten. Never having attended a mosque I can only imagine that the same holds true for the Qur'an. Except of course for the extremists.

In order to become a …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

@Rouf mir

Can anyone please tell me the purpose of life and all this drama in this universe?

No. It's up to you to determine your purpose on your own. If anyone else tries to tell you your purpose, walk away or better yet, run. As far as I am concerned, as good a personal philosophy as any has been proposed by Wil Wheaton. That philosophy is "don't be a dick".

Why was this earth created?

The universe is not concerned with "why". "Why" is a concept created by people. The universe just is. I am more interested in "how" than "why".

Why we were born?

You were born because at some point your parents had intercourse. Don't read anything more into it.

Why so much harderships in the life?

A few billion years of evolution clearly indicates that for most living things, life is not easy. Except for a privileged few, hardship is the norm.

What will happen after death? Where will we be?

Remember what it was like before you were born? Same thing.

It is not thaat 'Hani' is trying to defy his religion. It is the fact that he is sincerely trying to protect us from the fire of hell as per his religion.

I have found that the same people who tell me that my religious beliefs are wrong (in order to save my immortal soul, of course) seem to get very upset …

mike_2000_17 commented: Awesome! +0
stultuske commented: love the neutral and well thought answers, allthough I think the real "Reverend Jim Ignatowski" would have a completely different set of answers :) +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The easiest way to check is to use a regular expression. Here is an example for your particular requirements:

Imports System.Text.RegularExpressions

Public Class Form1

    Private Sub btnTest_Click(sender As System.Object, e As System.EventArgs) Handles btnTest.Click

        If Regex.IsMatch(txtTestStr.Text, "^[2-9]\d{2}-\d{3}-\d{4}$") Then
            txtResult.Text = "Match"
        Else
            txtResult.Text = "No Match"
        End If

    End Sub

The above sub compares the text in the TextBox, txtTestStr.Text, with the regular expression "^[2-9]\d{2}-\d{3}-\d{4}$" and displays the result in another text box. The regular expression can be broken down as follows

    ^       the start of the string
    [2-9]   any digit in the range 2 to 9
    \d{2}   exactly two other digits
    -       a dash
    \d{3}   exactly three digits
    -       a dash
    \d{4}   exactly four digits
    $       the end of the string

You can find many other useful patterns here

daniel955 commented: nice +1
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I think the easiest way would be to create your own msgbox form. Make sure it has a fixed width font like Courier New and display is as Modal.

alexandra.lopez.94043 commented: how do I create a message box form sir? +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Or even

TextBox.Visible = Ctype(sender,CheckBox).Checked
Begginnerdev commented: Nice, I have never used that method. Good to see a shorter, more effecient way of doing it. +5
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I have no idea what "phBAH.phTabControl" is. Start a new (blank) project. Add a few textboxes and a few other controls at random. Don't bother setting any properties or names other than the defaults. Now replace the existing code with the following:

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        For Each ctrl As TextBox In Me.Controls.OfType(Of TextBox)()
            AddHandler ctrl.GotFocus, AddressOf TextBox_GotFocus
            AddHandler ctrl.LostFocus, AddressOf TextBox_LostFocus
            ctrl.Tag = ctrl.BackColor
        Next

    End Sub

    Private Sub TextBox_GotFocus(sender As Object, e As System.EventArgs)
        Dim txt As TextBox = sender
        txt.BackColor = Color.LightGray
    End Sub

    Private Sub TextBox_LostFocus(sender As Object, e As System.EventArgs)
        Dim txt As TextBox = sender
        txt.BackColor = txt.Tag
    End Sub

End Class

After consideration I thought it was better to have separate handlers for "got" and "lost" focus. Just my opinion. In any case, try the above code. You can even set the text boxes to have different background colours at design time. The starting colour will be restored after the control loses focus.

iFrolox commented: Works :) +0