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

Why not have the remaining letters in a dropdown combobox. Once a letter has been guessed you remove it from the combobox. That way there is no need to validate input.

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

I recently had to send my laptop back to Dell for some warranty work and when I got it back it had the same problem as before it went in. I was told that they replaced the system board but I am having my doubts. I'm going to send it back but before I do, is there any way short of opening up the case and looking (which I don't want to do) to uniquely identify the system board so that when I get it back I can verify that they did or did not replace the board?

The problem I am having is with the power supply. I get frequent pop-ups stating The AC power adapter type cannot be determined. Your system will operate slower and the battery will not charge. Please connect a Dell 90W AC adapter or higher for best system operation.

I also get a similar message on every boot requiring me to Press F1 to Continue, F2 to enter Setup or F3 to suppress further messages

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

I have one suggestion (not necessarily a great one). Set a class variable in the main form (call it something like ShowForm). Set it to True initially. Have a timer on the main form and set the interval to 1000. In the timer Tick event do

Me.Visible = ShowForm

You can modify the value of ShowForm from another thread. The Tick event in the main form will do the actual show/hide. If you need the show/hide to be more reactive then shorten the Interval value.

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

I use CutePDF Writer. It's free and doesn't have to be run on a server. It just installs as a pseudo-printer and can be installed on on the workstations for whichever users need it. I haven't tried this but perhaps it could also be installed as a shared printer if it needs to go on the server.

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

Or you could use the RichTextBox control and write to an rtf file which is readable by Word.

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

Unless you count hedge-fund manager as a career.

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

New World Symphony - Dvorak.

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

One of the things I have been steadfastly avoiding is writing code to print stuff. Most of what I want to print is from withing apps like Outlook or Word that already provide that functionality. But I finally ended up having to bite the bullet. What I ended up with was not pretty but it is (except for one flaw noted in the comments) adequate. I present it here for comments. Perhaps it will be of use to someone else.

In a nutshell, printing requires that you "draw" each item on the page, be it text or graphics. As such, you can't just stream text to the page. You must calculate the position of each string. When you print a document, the PrintPage event gets fired until there are no more pages to print. As long as you set e.HasMorePages to True before you exit the PrintPage handler the PrintPage event will continue to fire.

As I quickly learned by starting with a Microsoft example, if you try to print a line that is too long to fit on the page, it will just get truncated. You must provide the word wrap functionality by determining what parts of the line will fit on the page and what will not. The sample code does this by tokenizing each line of text and rendering each token separately. If a token will not fit in the remaining line then it is saved for the next line.

This is my first attempt at printing …

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

If you are only interested in the total number of vowels and not the number of each vowel then a simpler approach is

Dim str As String = "the quick brown fox jumped over the lazy dog"
Dim numVowels As Integer = 0

For Each ch As Char In str.ToUpper.ToCharArray
    If InStr("AEIOUY", ch) > 0 Then numVowels += 1
Next

MsgBox("number of vowels = " & numVowels)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Make all cells in row 1 blue.

For Each c As DataGridViewCell In DataGridView1.Rows(1).Cells
        c.Style.BackColor = Color.Blue
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

"sender" is a generic object. I cast it to a Timer object so I can access the Enabled property. You could also do

Dim t As Timer = sender
t.Enabled = False
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In VB.Net (with explicit type) the syntax would be

Dim reftext As TextBox = Me.Controls("TextBox1")
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you check out my code snippet BackgroundWorker IP Monitor it shows how to use Delegates to access the textbox from another thread. I think that is what you will have to do.

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

1000 milliseconds is one second so the statement stands.

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

Neo-Citran (bloody flu)

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

The Timer.Tick event fires once every Interval milliseconds so you don't need a loop inside the handler. If you are counting down to zero then just stop the timer at that point.

Private Sub ... Handles timer1.tick

    If datetime.Minute > 0 Then
        datetime.AddSeconds(-1)
    Else
        DirectCast(sender,Timer).Enabled = False
    end if
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Simpler way is

Date.Today.ToString("yyyyMMdd")
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Is it still possible to get a virus in the master boot record? If so, you might have to recreate this.

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

Jack Reacher isn't a bad guy. Just bad a$$. Tom Cruise? They might as well have cast Billy Barty (if he were still alive).

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

Index is a reserved word. You can either rename the field to something other than Index, or you can specify the field as [Index] as in

Dim myUpdateQuery As String = "UPDATE Sensor_Table         " & _
                              "   SET Equipment_ID = @id,  " & _
                              "       Location = @Loc,     " & _
                              "       Supervisor = @Sup,   " & _
                              "       Alarm_Start = @Astr, " & _
                              "       Alarm_Stop = @Asto   " & _
                              " WHERE [Index] = @LBIndex"
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I once left one comma out of a call (from FORTRAN) to an assembler routine. It caused all kinds of problems in a production system and took weeks to track down. It looked something like

CALL MDREAD(PARM1,PARM2,PARM3,,,,,,,,,,,,,,,TEMP)

If you are done then please mark this thread as solved.

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

Jim Caviezel was also in Frequency (he played the son of Dennis Quaid) and in the remake of The Prisoner which I refused to watch because it was completely opposite to the intentions of Patrick McGoohan. It was as unfaithful to the original as the Star Trek reboot was to its.

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

To validate a user you can use

Private LoggedIn As Boolean = False   'class level variable

Private Sub btnLogIn_Click(sender As System.Object, e As System.EventArgs) Handles btnLogIn.Click

    Dim con As New OleDbConnection("Provider=SQLNCLI10;Server=.\SQLEXPRESS;Database=mydb;Trusted_Connection=Yes;")
    Dim qry As String = "SELECT COUNT(*) FROM test3 WHERE username = ? and pswd = ?"
    Dim cmd As New OleDbCommand(qry, con)

    cmd.Parameters.AddWithValue("col1", txtUser.Text)
    cmd.Parameters.AddWithValue("col2", txtPswd.Text)

    con.Open()
    LoggedIn = cmd.ExecuteScalar <> 0
    con.Close()

End Sub

PS, with SqlClient you could do (named parameters)

Dim qry As String = "INSERT INTO test3 (username,pswd) Values(@user,@pswd)"
Dim cmd As New OleDbCommand(qry, con)

cmd.Parameters.AddWithValue("@user", "Barney")
cmd.Parameters.AddWithValue("@pswd", "Rubble")
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Wow. Marathon gaming session. Just got the computer back.

To the best of my knowledge, oledb lacks the parameter naming used by SqlClient so you have to use sequential parameters as in

    Dim con As New OleDbConnection("Provider=SQLNCLI10;Server=.\SQLEXPRESS;Database=mydb;Trusted_Connection=Yes;Connect Timeout=15;")
    Dim qry As String = "INSERT INTO test3 (username,pswd) Values(?,?)"

    Dim cmd As New OleDbCommand(qry, con)

    cmd.Parameters.AddWithValue("col1", "Barney")
    cmd.Parameters.AddWithValue("col2", "Rubble")

    con.Open()
    cmd.ExecuteNonQuery()
    con.Close()

You indicate the number of columns in the insert query by adding one "?" for each column. Each instance of cmd.Parameters.AddWithValue replaces the next "?" with an actual value. In your case the query would look like

Dim qry As String = "INSERT INTO ADCBaleCutterLC " & _
                    " (Old Formula,New Formula,Raw Material Name," & _
                    "  Raw Material Number,Batch Number,Preformed By," & _
                    "  Preformed by Date,Verified By,Verified By Date) " & _
                    "VALUES (?,?,?,?,?,?,?,?,?)"

and your calls to AddWithValue can stay the way they are. Note that you don't need the single quotes around the field names. Side note - I have always found that blanks in field names are a problem. I suggest replacing them with underscores or using camel case. ie

Raw_Material_Name
RawMaterialName

Let me know how that works.

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

Have you seen the second Berserk that was just released?

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

When the boys get done playing their Christmas (networked) game I'll have a look. While I am waiting, could you possibly post the structure and types of the relevant database tables? If they are not overly large I'll recreate them here for testing.

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

He's home from the hospital. Had surgery for a hernia last night.

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

But then someone has to go through all replies to all posts to rate how relevant each post is to the question. If the OP doesn't provide full background and someone posts

You need to provide more details such as

  1. The exact text of the error messge
  2. The line of code where the error occurred
  3. The structure (including types) of all database tables and columns
  4. The database being used (mySQL, MS SQL, Oracle, etc)

Do you consider that as relevant even though it doesn't answer the question, even though it is very useful in getting to the root of the problem? When others are browsing the thread they are reminded to post complete information when asking a question. In that sense, the post is relevant to all questions.

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

What actor did you expect.... Dwayne Johnson?

I already said - Jim Caviezel. Of course, it wouldn't hurt for him to go on one of those Hollywood workouts pre-shoot like Gerard Butler did for "300".

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

Sorry. There were several shots of rum involved in the decision to post that and if it gets deleted I wouldn't be at all surprised.

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

As a long time fan of the Jack Reacher novels I will not be seeing the Jack Reacher movie. If you've read any of the books, you know that Reacher is described as six foot five inches and around 250 pounds of solid muscle. I can't believe they cast Tom Cruise. He had to stand on a box to film his scenes with Jamie Foxx in Collateral. The logic used by the producers was "there aren't any actors who match the physical description of Jack Reacher". I always thought Jim Caviezel could pull it off. He is almost tall enough (certainly closer than Tom Cruise) and he has the no nonsense detached persona down pat. But Tom Cruise? What a joke.

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

I have a bit of a family thing at the moment (had to take my father-in-law to emergency) so I can't address the bigger issue just now, but I have a suggestion to simplify the username/password verification. Have the user enter both the username and password at the same time then do

sql = "SELECT * FROM SecAccess " & _
      " WHERE User = '" & txtUser.Text & "'" & _
      "   AND Pswd = '" & txtPswd.Text & "'"

If the number of records returned is zero then either the username or password was incorrect and the login should fail. This is a lot simpler than retrieving the record then comparing fields. Note that I use names for the textbox controls that reflect their function. Always a good practice.

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

Just got back from watching The Hobbit at 48 FPS and 3D. Absolutely phenomenal.

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

I like your way better.

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

There are several examples of encryption/decryption in the VB.Net forum. Just click on Code Snippets and scroll through the list. As for the timer thing, based on what you have said, it would only work if the user left the program running all the time. A timer won't function when the program is not running and when the program restarts the timer will be reset (unless you save the current value on exit). What you can do is create an Application level Settings variable and encrypt and save the expiration date when the program is first run. The program can decrypt and compare against the system date/time on startup. If the user applies an extension then the program can rewrite the expiration date. Keep in mind that with a program like TimeStopper, the user can effectively freeze the system date for that program.

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

What a coincidence. I used to work for a pregnant goldfish.

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

Just rewatched an old favourite. Has anyone else seen "The Ruling Class" with Peter O'Toole?

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

At the time of the writing of Charles Dickens', A Christmas Carol, "scrooge" was a slang word synonymous with the word, "squeeze". And "a humbug" was a person who put on false airs as in a person who behaves as if everything is rosy when his life is anything but. What Scrooge disapproved of was the false display of gaiety and good will from people who behaved otherwise the rest of the year.

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

I keep wanting to make a very rude joke here but it would be unbefitting of my fake honorific.

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

Thank you for not posting yet another database question ;-P

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

What are you comparing the day part of the date to?

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

i live in rural area,on the isle of cape breton nova scotia

We drove there on our honeymoon in 1982. Beautiful place.

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

I've heard it said several times in recent days that "cars kill ##### people every year and we don't outlaw cars". I'm so [rude word] tired of hearing this. I'd like to point out that we have laws that regulate which vehicles are legal for use on public roads and which are not. We have laws that limit speed, emissions, noise. Vehicles must pass periodic safety checks. We have laws that determine who can drive and when. But any mention of regulating guns immediately brings the response "the government wants to take your guns away". Apparently our childrens' lives are nothing more than colateral damage in the war to regain the reins of power. And judging by yesterday's statement from the NRA (armed guards in every school), if guns is the problem then obviously more guns is the solution.

The gun nuts claim that the problem is not guns, but violence in the movies and on TV and violence in video games. Here in Canada we have the same movies, TV and video games as our neighbours to the south. Why is it, then, that we don't have anywhere near the same (proportional) level of slaughter here in Canada?

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

We don't offer help in that way. Private help doesn't benefit anyone else who might be looking for a similar solution. You also haven't given any indication what you need help with. If you are interested in help then please post your questions here.

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

Try the following (requires Imports System.Text.RegularExpressions)

Dim s As String = "[1-5][8-10][10-20][21-31]"
Dim rex As New Regex("\[\d+-\d+\]")

For Each m As Match In rex.Matches(s)
    Dim range As String = m.Value.Substring(1, m.Length - 2)
    Dim nums() As String = range.Split("-")
    Debug.WriteLine(range & " = " & nums(0) & " to " & nums(1))
Next

The output is

1-5 = 1 to 5
8-10 = 8 to 10
10-20 = 10 to 20
21-31 = 21 to 31

This will work even if you have spaces or other delimiters embedded such as

[1-5] [8-10] [10-20]   [21-31]
[1-5],[8-10],[10-20],[21-31]
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It is complaining because the compiler has determined that if the loop doesn't get executed then pname will not have a value to return at line 80. By assigning a null string when you Dim pname you ensure that pname will have a value no matter what execution path is taken. However, you have another problem. The last few lines of your function look like

    Return (pname)

    dr1.Close()
    myConnection.Close()

End Function

The two lines following the Return can never be executed because of the Return statement. You should reorder the lines as

    dr1.Close()
    myConnection.Close()
    Return (pname)

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

You can output the linies by displaying them in a TextBox or RichTextBox control. As a matter of convenience, the RichTextBox control has methods to read/write files. or if this is for debugging purposes you can use Debug.WriteLine, or Console.WriteLine for console applications. In this case something like

Module Module1

    Sub Main()

        Dim lines() As String = System.IO.File.ReadAllLines(myfile)

        For Each line As String In lines
            Console.WriteLine(line)
        Next

    End Sub

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

The regular expression

^\d+-\d+$

will match any string of the form

"#-#"

where "#" is any sequence of one or more digits. Once you have a match you can do a Split on the "-". For example

Dim s As String = "123-45"
Dim nums() As String = s.Split("-")

nums(0) will be "123" and nums(1) will be "45"

As for multiple intervals, was the example you gave "[1-5][8-10]" an actual string to parse in the exact format? It would be easier to parse if the separate ranges were separated by blanks or commas as in "12-15 23-49 102-119" or "12-15,23-49,102-119"

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

You have to convert the string to a number first. In your case that would be

If CDec(CapAmount) >= 3000 Then