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

Here's one way

For r As Integer = 1 To CInt(txtNumRows.Text)
    dgvMyGrid.Rows.Add(New DataGridViewRow)
Next
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I would not like anonymous comments. I think if you have something to say then you should be willing to have your name attached to it especially when what you have to say affects the reputation of another user. Having said that I have seen how anonymous voting can be abused. We have seen users whose posting quality has tanked because another user had gone through the forums and downvoted averything by that user. Something that could alleviate that would be to disallow multiple downvotes within a given time frame, especially against a particular user. However, this would not prevent someone from downvoting one post. I'm assuming that this arose from the regex thread in the vb.net forum. In that case the user who downvoted had three (actually four) options:

  1. downvote anonymously
  2. downvote with comment
  3. reply in-thread
  4. do nothing

The first choice gives you a hit on your posting quality whereas the second choice affects your reputation. As you saw in the thread, I chose option 3. I would have chosen option 4 had it not been for your reaction to the downvote (which I will state again that I was not responsible for). While I found your proposed solution overly complex for the problem, the OP was free to ignore it.

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

Perhaps something like this

'This assumes that only valid selections appear in cboSearchType

Dim sql As String = "SELECT * FROM BusinessInfo WHERE "

Select Case cboSearchType.Text

    Case "Accredited Month"
        sql = sql & AccreditationDate " & " like '" & cboMonths.Text & "%'" 
    Case "Accredited Year"
        sql = sql & AccreditationDate " & " like '" & txtSEARCH.Text & "%'" 
    Case "Applicant Name"
        sql = sql & ApplicantName " & " like '" & txtSEARCH.Text & "%'" 
    Case "Business Name"
        sql = sql & BusinessName " & " like '" & txtSEARCH.Text & "%'"  

End Select

With grdSearchResults

    .Rows = .Rows - .Rows + 1

    If rs.State = 1 Then rs.Close()
    rs.Open sql, con

    While rs.EOF = False
        .Redraw = False
        .Rows = .Rows + 1
        .Row = .Rows - 1
        .Col = 1: .Text = grdSearchResults.Rows - 1
        .Col = 2: .Text = rs!BusinessName
        .Col = 3: .Text = rs!ApplicantType
        .Col = 4: .Text = rs!ApplicantName
        .Col = 5: .Text = rs!BusinessAddress
        .Col = 6: .Text = rs!AccreditationDate
        .Redraw = True
        rs.MoveNext
    Wend

End With

Although I should point out that you might not want to keep the connection open. The preferred method is to keep connections open only as long as they are immediately needed. In that case you should do something like

If con.State <> 1 Then con.Open()

rs.Open sql, con

'the loop goes here

rs.Close()
con.Close()
Stuugie commented: Just because the OP should have, nice work. +5
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I don't have Access installed so I can't test this but try

cmd.CommandText = "SELECT COUNT(*)" &
                  "  FROM Userr" &
                  " WHERE StrCmp([UserID],?,0) = 0" &
                  "   AND StrCmp([User Password],?,0) = 0"

cmd.Parameters.AddWithValue("@parm", txtUserName.Text)
cmd.Parameters.AddWithValue("@parm", txtUserPassWord.Text)

con.Open()

Dim numrec As Integer = cmd.ExecuteNonQuery()
MsgBox(If(numrec = 1, "match", "no match"))

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

I didn't even consider seafood ;-P

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

As has been pointed out, there are too many variables to be able to answer that question. Aside from questions about quality of land, length of growing season, etc., there is the question about whether each family/group is expected to be self sustaining. I think we can discount pesticides and fertilizer. Arable land when properly maintained using crop rotation and fallowing does not require fertilizer. My grandfather was a market gardener as were all four of his sons so I have a little knowledge about this. None of them used fertilizer or pesticides. However, none of their farms could be considered self sustaining - all raised vegetables, no animals other than the horses my grandfather used for labour.

Another question is whether or not that land is to be worked by hand/animal power or by powered machines. My grandfather used machines pulled by horses. My father had a tractor and other powered machines.

I think the question does not have a simple answer, and a more complex answer that takes into account all the variables would require time and resources beyond anyone here. Having said that, I think someone with experience in agriculture and nutririon might hazard a guess as to the maximum number of people this planet could theoretically support under ideal conditions.

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

But Americans (and Canadians) eat a lot of beef which requires much more land per pound of protein to produce than other forms of protein so that skews the numbers. Also, what is the definition of "living requirements"? Is it bare minimum to keep alive or comfortably alive? Are we talking poverty level subsistence or middle class?

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

I'm not sure I understand what you are asking but if you want to do a case sensitive selection on the database you can do

SELECT *
  FROM Userr
 WHERE [UserID] COLLATE Latin1_General_CS_AS = 'username'
   AND [User Password] COLLATE Latin1_General_CS_AS = 'password'

If you are only interested in whether the case sensitive username and password are present then just do SELECT COUNT(*) rather than SELECT *

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

Small correction then. Add a ByRef to

Private Sub getDaysOut(ByRef intDays As Integer)

so that the entered value of intDays is returned to the calling code. I have to say, though, that by insisting you use a Sub rather than a Function, your instructor is teaching you bad habits.

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

Who is to say how technology will impact your career. For example, I was a real-time programmer for a major electric utility (generation, transmission and distribution). You may recall a few years back when they had that cold fusion fiasco. As unlikely as it was to be real, had it been real it would likely have bankrupted my company. Even though the distribution network would still be needed, how do you pay off the massive debt incurred by building hydroelectric dams that are no longer needed? The product your company makes today could be made as obsolete as buggy whips by the most unforeseen tech change.

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

Interesting. Your OP was about calculating late fees yet you post an unrelated project to calculate the average of midterm and final exams. As for "using modules, not functions", that statement does not apply because you can use functions in modules.

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

You should be using TRY/CATCH rather than On Error. Also, because you haven't included the code for ExecSQL or the text of any error message there is no way to offer meaningful suggestions.

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

You might try rewriting it as a function without the global as in

Private Function calculateFees (ByVal intDays As Integer, ByVal decFee As Decimal) As Decimal

    If intDays <= 3 Then
        return decFee
    Else
        return CDec((intDays - 3) * 1.5 + decFee)
    End If

End Function

I'm assuming decFee is defined as Decimal. In the calling code you would do

fee = calculateFees(numdays, decfee)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Clearly it's not my day to be answering questions.

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

OK. Now that I'm awake (I really shouldn't answer questions at 4:00 am), you never call GetExamGrades so your values are always 0.

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

How about changing

dblAvgTotal  CalculateTotalAverage(dblMidTerm, dblFinal) 

to

dblAvgTotal = CalculateTotalAverage(dblMidTerm, dblFinal) 
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

"You'll have to forgive me. I'm Old." - Phil Fish (Abe Vigoda on Barney Miller)

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

My guess is that 4k files would be around 4*1024 bytes.

Seriously though, the size of 8 minutes of 1080p could vary greatly depending on the bitrate, frequency of keyframes, motion, etc. A video with low motion should have higher compression. A video with lots of motion or frequent scene changes would have a much lower compression. The same variability would occur no matter what the resolution.

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

Go to Organize, then Folder and Search Options. In the Folder Options dialog box, select the View tab. Scroll to the bottom and you will see

When Typing into list view
    o Automatically type into the Search Box
    o Select the typed item in the view

Make sure you have the second option selected. I suspect you are using the first option. Make sure you click Apply to Folders after you click Apply.

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

It is possible to portray higher dimensional objects in lower dimiensions but the result always contains distortions. Just look at maps. Most maps (in the projection which is most commonly used) show Greenland as inordinately large.

In the same way we can portray a cube in two dimensions

cbd01b4660a6ec4ebad71de589f69069

and a tesseract (hypercube or four-dimensional cube) in three dimensions (putty and straws work well), or even two dimensions.

96be8ebd9e9223c99aa3846a1f01d57a

It is also possible that we cannot perceive other dimensions because of scale. When standing on the prairies we perceive the world as flat, not spherical, but from space the actual shape is apparent. If you were reduced to the size of an ant and were standing on a soda straw you could berceive the surface as cyllindrical, but if you were the size of a microbe your perception would be substantially different.

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

I've been programming since the 70s and I still haven't created one.

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

Just add more clauses to the ORDER BY as in

ORDER BY fld1 DESC, fld2 ASC, fld3 ASC
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try downloading a linux livecd and booting off that. Copy the files to another folder/device then delete the bad folders.

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

You do the INSERT when there is no value entered for locid. Is this really what you want? Also, why are you using ExecuteReader for the INSERT? Use ExecuteNonQuery instead. You use ExecuteScalar when you are returning one value or ExecuteReader when you are returning more than one value. In your case you are not returning any values.

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

If you want the speed then you can always invest in an SSD.

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

The one thing about most languages is even if you lose the indentation you can always recreate it. In Python, if you lose the indentation you are pretty much screwed.

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

If you are using OleDb then try

access = "UPDATE tbl_location WHERE locid = ? SET locname = ?, locadd = ?"
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I can't say enough good things about SpinRite

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

See here

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

Regardless. You are still asking for someone to do your homework for you. You haven't shown us that you have put in any effort.

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

When a good brand (Toshiba) makes a bad laptop, admits to fault and still charges you to fix/replace the laptop, in my mind that brand becomes a bad brand.

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

FORTRAN has always been the winner for number crunching because it produces the most highly optimized code. C/C++ runs a close second but is still slightly behind. The major reason for FORTRAN's ability to optimize is the result of how C/C++ manages arrays. In C/C++, arrays are managed through pointers. As such, the compiler can not make the assumption that two arrays do not overlap. FORTRAN has true arrays and the compiler can determine that arrays are non-overlapping and can split array calculations over multiple processors. In the 1999 update to the C specification (C99) arrays could be specified as not overlapping so this definitely narrowed the gap.

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

Let's look at the statement

Dim MySQLStatement As String = "INSERT INTO player_log (Last_Name, First_Name) VALUES (' " & TxtLastName.Text & " ' , ' " & TxtFirstName.Text & " ')"

If we plug in values "Jim" and "Jones" it evaluetes to

INSERT INTO player_log (Last_Name, First_Name) VALUES (' Jones ' , ' Jim ')

Do you see the problem? You are adding a blank at each end of the names. Try changing it to

Dim MySQLStatement As String = "INSERT INTO player_log (Last_Name, First_Name) VALUES ('" & TxtLastName.Text & "' , '" & TxtFirstName.Text & "')"

If you used parameterized queries as I suggested in your other thread on this topic you wouldn't have had this problem.

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

I would code it as

Private Function UserExists(fname As String, lname As String) As Boolean

    Dim con As New MySqlConnection(SQLConnect)
    con.Open()

    Dim cmd As MySqlCommand = con.CreateCommand
    cmd.CommandText = "SELECT COUNT(*) FROM player_log" &
                      " WHERE last_name  = '" & lname & "'" &
                      "   AND first_name = '" & fname & "'"

    UserExists = cmd.ExecuteScalar > 0
    MsgBox(IIf(UserExists, "User exists", "User does not exist"))

    con.Close()

End Function

and call it as

If UserExists(txtFirstName.Text, txtLastName.Text) Then

I'm assuming your objects for MySql are correct. I use MS SQL.

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

You don't need a datareader. All you need to know is if you have a record that matches the username and password.

cmd.CommandText = "SELECT COUNT(*) FROM userinfo" &
                  " WHERE usname =     '" & textbox1.Text & "'" &
                  "   AND [password] = '" & textbox2.Text & "'"

If cmd.ExecuteScalar <> 0 Then
    'user is valid
Else
    'user is not valid
End If

But you should really use parameterized queries

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

I've never personally had a problem with Dells and there have been five in my immediate family. On the rare occasions I've had to get service it was always easily arranged with a fast turnaround time. I was even able to get a replacement battery out at the cottage in the middle of nowhere.

I won't condemn Toshiba forever, but a few years ago we had a problem with a batch of them at the office. A design flaw caused the hard drives to fail on a regular basis. Toshiba admitted the problem was theirs but refused to repair/replace. We are talking about 10-15 laptops. That decision by Toshiba caused my company to switch from Toshibas to Thinkpads. In a corporation of 5000 people, that amounted to a hefty chunk of change that Toshiba lost.

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

We are not going to teach you everything you need to know about databases. I suggest you do a little googling. You can start with W3 SQL Tutorial.

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

And even if it is read only you can still set the background colour to anything you want. Or you could just use a label control.

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

Please post your code. My guess is you are modifying the in-memory copy of the table but not saving it to the database.

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

Then you can get the next available ID number by

SELECT nextID=MAX(ID)+1 FROM mytable

Just remember not to specify ID when you save the record or you will get an error.

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

Do you mean that when you bring up a blank form (so you can create a new entry) the ID number of the record that will be added is displayed? The answer depends on whether or not there is only one user hitting the database at a time.

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

Try

rec.Open "select * from Body_Markings_new where [Part Number] like '%" & txtsearch.Text & "%' ", conn, adOpenDynamic, adLockOptimistic

It's my own preference, but I always avoid putting spaces in field names. It always leads to problems like this.

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

The last four parameters are

forward    
    true to move forward in the tab order; false to move backward
tabStopOnly  
    true to ignore the controls with the TabStop property set to false; otherwise, false.
nested
    true to include nested child controls; otherwise, false.
wrap
    true to continue searching from the first control in the tab order after the last control has been reached; otherwise, false.
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I think a better way to do this would be

Private Sub TextBox1_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    If e.KeyChar = vbCr Then
        Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
        e.Handled = True
    End If
End Sub

Private Sub TextBox2_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
    If e.KeyChar = vbCr Then
        Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
        e.Handled = True
    End If
End Sub

Or even

Private Sub TextBox1_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress, TextBox2.KeyPress
    If e.KeyChar = vbCr Then
        Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
        e.Handled = True
    End If
End Sub
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

There's an old saying (I don't know who said it first) that goes "I write all my time critical routines in assembler and all my comedy routines in BASIC.".

Having said that, you will usually find me in the vb.NET forum.

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

Nobody can say with any certainty what languages will still be around in 20 years. Even 5 years is difficult with some. If you want to port old VB programs with as little difficulty as possible I suggest just going to vb.net. I think you'll find porting vb to C++ will be much more difficult. A few years back (closer to 20) I had to port a very large and complex program from vb to FORTRAN, and then later on to C. It required a complete rewrite both times and neither experience was pleasant. The positive aspect, however, was that a complete rewrite allowed me to make great improvements in the design.

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

If a field has been designated as AUTONUMBER then you cannot include it in the insert query. If you want to insert all records from the temp table into the permanent table you must specify all the fields except the AUTONUMBER field in the select statement. For example, if I a table

table_1
ID          int (PK AUTO NUMBER)
field1      varchar(50)
field2      varchar(50)

I can create a temp table by

SELECT * INTO temp FROM table_1

but to add those records back into table_1 I must do

INSERT INTO table_1 SELECT field1, field2 FROM temp

Because you said the temp table is a copy (in structure) of the permanent table then the ID field is also AUTONUMBER and wiill not allow you to insert a record which has the ID field.

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

I don't believe the first query will do anything. The syntax is

WHERE [SOMEVALUE] NOT IN (LIST OF VALUES)

however your syntax is

WHERE [SOMEVALUE] NOT IN (RECORDSET)

What exactly are you trying to do? The second query should work but because I don't know what you are trying to do I can't say whether it will do what you want.

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

Try doing a SELECT COUNT(*) on the record with that ID. If you get a result of 0 then the record does not exist.

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

Try removing the single quotes from the numeric fields as in

qry = "SELECT * FROM [per_diem_accomodation] " &
      " WHERE [project number]  = " & projcode & 
      "   AND [employee number] = " & empcode  &
      "   AND [current month]   = '" & resultdate & "'"

Also, you didn't say what the backend database was. If it is Access then you should delimit the date with # instead of single quotes. In any case you should be using parameterized queries.