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

I guess you didn't look here. I wrote the ListView Column Sort Demo code snippet just for that. You really should browse the Code Snippets.

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

I heard about one airline that is going to start charging fares by the pound. If you weigh 200 (pounds) you get one fare. If you weigh 400 then you pay double.

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

Perhaps what we are seeing is a proliferation of people who don't bother to think for themselves rather than people who can't think. Without getting into a whole political/religious debate here, my impression (which to my knowledge hasn't been tested scientifically) is that too many people believe what they are told without bothering to think about whether the facts support what they are told. There have been scientific studies, however, that indicate that when people are shown irrefutable proof that contradicts what they believe, they dig in their heels and believe even more strongly.

Four words that always make me cringe when I watch the news are a new study shows. When every few months a new study shows exactly the opposite of what the last new study showed, I can understand why most people just give up.

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

Keep in mind that ndorsements are supposed to be a recognition of a member's expertise in a particular area. It is not supposed to be a "tit for tat" system where a member says "if you endorse me then I will endorse you". Make sure that when you endorse someone it is for the right reason.

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

It's a beautiful day at the cottage except for a little interference from the local wildlife (check out my new hat). The little buggers don't seem to be afraid of anything.

0dae4c2f9f21fb5cb7c5bbd4c0a8c1c3

Stuugie commented: Wow! +0
LastMitch commented: Wow! is that real! +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

When I was a boy of 14, my father was so ignorant I could hardly stand to have the old man around. But when I got to be 21, I was astonished at how much the old man had learned in seven years. - Mark Twain

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

If you are doing an UPDATE rather than an INSERT then you will be overwriting existing values so tagging the records with the date of the update won't help. How about the following structure

Update_Date (PK)
CB_ID int (PK)
CB_Mnemonic_ID int (FK)
CB_Value decimal (18,10)
CB_Year int
CB_Quarter int

and make the primary key a compound key consisting of the update date and CBID. That way you retain all historical data. This is what I did with the Dovercourt EMS analog point data. We had to maintain the historic values. At 8000+ points every hour the data does tend to pile up (around 400 meg per month).

Stuugie commented: Thanks for the feedback +2
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I plan to live forever. So far, so good. - Stephen Wright

I'm not afraid of dying. I just don't want to be there when it happens. - Woody Allen

Stuugie commented: lmao, good quotes! +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

75c23da3f85636d5aa1db9fc4b502f32

This post has no text-based content.
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try using the Random class as in

Dim rand As New Random
Randomize()
Me.Text = rand.Next(1, 11)

rand.Next(min,SortOfMax)

returns a random number in the range min to SortOfMax-1

so rand.Next(1,11) returns a random integer from 1 to 10. I use the name SortOfMax because the Microsoft documentation used to say Next(min,max) which was highly misleading. Now it says

Next(Int32, Int32) Returns a random number within a specified range.

which is still misleading.

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

All I require of a religion is that it be tolerant of those who do not agree with it. - Roger Ebert

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

Sorry. I don't do C#. Perhaps someone else can step in.

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

Don't ask the barber if you need a haircut. - Warren Buffet

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

Civilization has always been a few very gifted people making advances and dragging the rest of us along behind. If you want to see a great commentary similar to what I said earlier, watch the first 10-15 minutes of the movie, Idiocracy. Th rest of the movie is pretty lame but the opening is spot on. I also suggest the short story, The Marching Morons by C. M. Kornbluth.

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

Thousands of years ago the attributes that improved your chances of survival were things like intelligence, speed, agility, visual acuity, etc. Once we started to form communities the attributes that improved your quality of life, and therefore your chances of reproducing related to your usefulness to the community. If you were a superior flint knapper or spear maker then you could trade your wares for things you needed to survive. Throughout all this, your genetic makeup was, of course, also critical. If you were born with defective body parts or genes that manifested before or during your procreative years then you were less likely to continue your line. So I suppose a fair measure of your "survivability" would be the number of offspring you bore or sired.

So looking at today's society using the same measure it would seem that the attribute that improves survivability is poverty (at least in North America). Without doing a serious study, my understanding is that those close to the bottom of the economic ladder are the ones having the most babies. There are exceptions of course but for every ultra-rich megafamily there are a hundred octo-moms. Intelligence no longer seems to be a factor.

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

Prepare yourself. Are you sitting down? Here it comes...

I completely agree with you.

There. I said it. And it felt good.

Some day in the future man will evolve without brains due to lack of use.

Future? I've seen plenty of examples around already.

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

Confiscating computers from people is also futile

If the point is trying to decrypt your data, then yes. If the point is to coerce you into giving up the password or punishing you for refusing to do so, then no.

Whatever the technique, it would be very difficult

These days one can always make something that will explode. If the security people are checking shoes then you make exploding underwear. Now that we can 3D print guns out of resin people will be sneaking those on planes. It's the Red Queen's race.

As for encryption, Truecrypt offers a hidden, undetectable encrypted container in a container. But as I said, if your laptop is suspicious (or you are) your laptop can be confiscated without reasonable cause.

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

For what it's worth please see here

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

The following is taken from the article I referenced titled Laptop Searches at the Border: What the Revised U.S. Guidelines Say

U.S. Customs officers have the authority to search and detain any device capable of storing electronic information for any reason; they can examine the electronic device without the traveller present; they can copy from the device or “detain” the device; and they do not need to obtain the traveller’s consent to conduct the search. “Electronic devices” can include computers, BlackBerrys or similar devices, cell phones, travel drives, DVDs and CD-ROMs, cameras, music and other electronic media players.

The fourth amendment is the part of the Bill of Rights which guards against unreasonable searches and seizures. If the customs officers now have the authority to search and detain any device capable of storing electronic information for any reason then the new guidelines have apparently nullified the fourth amendment. My apologies if I confused this with the powers granted by the Patriot Act.

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

In America there is the Bill of Rights

You have the Patriot Act now which gives the government the power to do pretty much what they want. As I posted earlier in this thread, here's what the Revised US Guidlines say. As the customs officials are confiscating your laptop because they don't like your demeanor just see how far you get shouting "fourth amendment". I almost got turned back at customs for having an apple. I mean the fruit kind, not the computer kind.

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

In my house we taught our children to eat well (lots of vegetables and lots of variety) and to limit junk food. 99% of our meals were made from scratch. People who claim they don't have the time are wrong. My wife and I both worked and we managed with no trouble. Precooked and overly processed food (here in Winnipeg) is also more expensive than buying the raw goods (on sale) and preparing it yourself.

matthewwhite011 commented: This is the key to better health. Parents need to understand that fast foods and other processed foods are killing our new generation. And if there is something left, it is now being overcome by Xbox and Playstation stuff. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The idea that you can be forced to reveal private data is just a mistake.

That's why I said "at the risk of having your computer confiscated". You can always claim you don't know the password (and there are legitimate reasons why you might not), but customs can then refuse to return your computer.

they know before they start that they'll never find anything anyone seriously wants to hide.

Stupid people do stupid things. Smart people do stupid things. By your reasoning, they shouldn't bother looking for weapons either because a really clever person would find a way to get one on board. Every few months I read about some dude who got caught with child porn on his computer in his home. A smart person would have hidden it better. I'd say that a smart person wouldn't have had it at all but I suppose the things that drive a person to crave child porn are unrelated to one's intelligence.

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

Well, the idea is to encourage everyone to start tagging their posts.

It's hard enough getting users to create a decent title let alone a coherent question. I can't see them going to the trouble of creating sensible tags.

ndeniche commented: This is the answer to the existence of the universe +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I can only encourage you to drop this subject like it was a hot rock.

I don't advocate trying to smuggle digital contraband through customs, but I think the idea that you can be forced to reveal private data at the risk of having your computer confiscated is a subject worth discussing. In Canada, we had a member of parliament who had the audacity to state that anyone who was against blatantly illegal invasions of privacy was siding with the child pornographers.

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

Why would terrorists resort to trying to smuggle any kind of data, encrypted or otherwise, across international borders on physical media? This is just stupid. All you have to do is encrypt it or hide it using steganography and park it online on a server somewhere - even as an attachment to a draft message in hotmail. Then you can access it from anywhere. No need to arouse the curiosity of a border guard with a physical device. If you use a technique like bit slicing you can divvy up the data into physically separate packages and store it online in several different places. If you do that then the data can't possibly be decrypted without having all the pieces and knowing how they go together.

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

If you can't upload files of that type directly you can always try zipping them first.

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

Veni Vidi Visa - I came, I saw, I shopped.

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

Easiest way is to wuery the database as in

SELECT COUNT(*) WHERE Username = 'joeblow'

If the returned value is 0 then the username is available. I suggest you use parameters to create the query string. How you do that depends on whether you are using OleDB or SqlClient. You can find examples of both here

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Begginnerdev commented: Nice resource! +8
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My code isn't bad. It's just misunderstood - Anonymous

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

If the PasswordChar property of the textbox is set to a character (such as asterisk) then anything you type will display as that character.

TextBox1.PasswordChar = "*"
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Any program that uses an expiry date is subject to being overridden by a program such as TimeStopper unless you can embed a call to an external (internet) time service periodically to get the actual date/time.

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

There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. Hoare

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

I recall a piece of software I installed at the office years ago. I think it was adTempus. When Ii got to the screen with the licence agreement I immediately checked I Agree and clicked Next. I was given a pop-up that stated "Ae you sure you read it over? You were only on the page for 4 seconds."

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

What mike said.

I find it useful to write the comments first and fill in the code as I go. For one thing it gives the code more of a narrative feel and helps to minimize the useless comments like "add one to x". A lot of what I wrote at Dovercourt was highly interconnected. The overall system diagram looked like a hundred spiders all holding hands. Ugly but necessary.

My boss, Geoff, because of his electrical engineering background, liked to document with what looked like wiring diagrams with lots of off-page connectors. I could never follow this, and because it was paper based, it was never up to date. Instead, I created a connections database where every node was either a process, a data source or a data sink. Each node could have any number of other nodes as inputs or outputs. A small GUI allowed you to select any node and it would show all the inputs to that node in one listbox and all the outputs in another. Double-clicking on any input or output would make that node the current node and show its inputs and outputs (along with useful node info such as who to contact when that node was having a problem or any useful debugging tips). If you are interested I believe Daryl Godkin is the person at Dovercourt currently maintaining my old code (assuming there is any of it left). If you get to see Daryl, ask to see his African …

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

If you pour crap in your gas tank your car will perform poorly. Same thing if you install crap on your Windows based PC. That's been my experience after a couple of decades supporting Windows PCs at work. The machines that didn't get screwed up by the users performed quite nicely.

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

To avoid confusion it is better to remove the blanks or replace them with underscores as in LastName or Last_Name

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

Or you can test the operands before you do the divide to see if the denominator is zero.

ddanbe commented: Life can be really simple. +14
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You need to include the following

Imports Microsoft.Office.Interop

Then you create a few objects

'create objects to interface to Excel

Dim xls As New Excel.Application
Dim book As Excel.Workbook
Dim sheet As Excel.Worksheet

You can open the Excel file by (use your own filename)

xls.Workbooks.Open("D:\temp\myfile.xls")

'get references to first workbook and worksheet

book = xls.ActiveWorkbook
sheet = book.ActiveSheet

You can access the rows and columns by

sheet.Cells(row, col) = 23   'or whatever value you want

'save the workbook and clean up

book.Save()
xls.Workbooks.Close()
xls.Quit()

releaseObject(sheet)
releaseObject(book)
releaseObject(xls)

Add the following Sub for cleanup.

Private Sub releaseObject(ByVal obj As Object)
    Try
        System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
        obj = Nothing
    Catch ex As Exception
        obj = Nothing
    Finally
        GC.Collect()
    End Try

End Sub

You may wonder why I create a variable to reference xls.ActiveWorkbook when I could just as well do

sheet = xls.ActiveWorkbook.ActiveSheet

The short answer is that if you do it as in the above line you will end up with Excel.exe tasks cluttering up your system (one for every time you run the app). I don't fully understand the reasoning. Trust me though.

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

If you are using a DataReader (dr) to read the data then why are you retrieving it from ds?

Begginnerdev commented: That too! :) +8
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm going to post this from the viewpoint of an English only speaking person (apologies to mike_2000_17 and others). The first language you should learn is English. The most important skill you will require is the ability to communicate clearly. It doesn't matter how gifted you are as a programmer in whatever language or languages you have mastered. If you can't communicate effectively with others then you will be spending a lot of time redesigning and rewriting. And that's if you even get through the interview process. I've seen job applications rejected because of too many grammatical errors. The reason given was that the lack of attention to detail on something so important as a job application (the first impression) would likely be reflected in that person's code. Simple mistakes such as

  • confusing their, there and they're
  • confusing its and it's
  • confusing your and you're

indicate one or more of

  • a lack of rudimentary grammar skills
  • a lack of proper care (no proofreading)
  • a disdain for proper grammar

You may quite correctly say that a person who confuses its and it's can still communicate clearly and be a gifted designer/programmer and you would be correct. However, you only get one chance to make a first impression.

And as jwenting so correctly pointed out, "The programming language you should know is the one you need for your current job at hand". The right tool for the right job.

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

As an adult I married my first love, we met in 8th grade.

Sweet. I love it when childhood romances work out. May you have many more happy years together.

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

You have to call Randomize() at the top or you will get the same sequence of numbers every time. Because you are working with such a small set of numbers (by the way, using (0,4) gets you a number from 0 to 3) you will very likely get duplicates. What you can do is generate a list of possible numbers such as {0,1,2,3,4} then generate a random number from 0 to list.Count - 1. That random number will be the index into the list. Once you pick that number you can remove it from the list thus ensuring it will not be repeated.

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

To illustrate the silliness, one time at work a female coworker was telling me about something she heard another coworker said, and to avoid having the filter obscure the actual wording I'm going to use "shit" instead of what she actually used (which was c-word). See how silly this is sounding already?

Anyway, the actual quote was "I can't believe she actually used the shit-word". To which I replied, if you were going to actually say "shit" why did you bother adding "word" to the end?

As for worrying about children perusing DaniWeb, I certainly wouldn't have wanted my young boys perusing a profanity-laden forum but once they were old enough to use the services here they were past the point of being warped by "colourful metaphors". In any case, the "keep it pleasant" rule would have increased the likelihood that offending posts would have been deleted anyway.

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

everyone should give the dead respect

No one should get respect unless it is earned. You don't get respect because you are a teacher, a parent or whatever. You earn respect for being a good teacher or a good parent. You get respect because of the person you are and the character you show. You don't automatically get it because you had the misfortune to die.

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

My two sons.

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

muslims aren't allowed to terrorize

Here's a news flash. Nobody is allowed to terrorize.

and you are to commit a major sin if you do terrorize

<M/> - You might be interested in this discussion that took place some tine back. Islam and logic

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

So what is the correct (ie your) pronounciation of Mikael? Is it me-KALE, mih-KALE, ME-kel, me-KEL? Am I getting close?

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

Consider it moved.

Begginnerdev commented: Thank you, Jim! +8
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

And one could certainly argue what it means to be "offensive"

That's the problem. There is no shortage of people who are ready to take offense. And if they are not offended personally, they are more than willing to be offended on behalf of some other person or group. I find that attitude extremely condescending. I am quite prepared to be offended on my own behalf. Then there are the people who go out of their way to find things to be offended about. For example, my wife and I very much enjoy the TV show, Dexter. If you watch the show you know that Dexter's sister has, shall we say, a colourful vocabulary. In the context of the character and because of the quality of the show we overlook the language, however, we have read several complaints by people who think the show should be taken off the air. As far as I am concerned, if the show offends you then just don't watch it.