Click here to Skip to main content
15,346,368 members

Comments by Luc Pattyn (Top 200 by date)

Luc Pattyn 28-Mar-22 15:43pm View
Your problem description is not OK:
- "prints fine", what does that mean?
- If you get one of the alerts, then tell us which.
- "not saved to database" is based on what?

And how about $conn? It appears only once in the code shown...

BTW: on top of it not working, you will get comments about:
- storing passwords as text,
- storing a confirmpassword rather than comparing it right away,
- being a candidate for SQL injection attacks.
Luc Pattyn 28-Mar-22 0:13am View
Is that a rhetorical question?\0
Luc Pattyn 16-Mar-22 18:39pm View
Hint: whatever you do, first create a sample data set (a small Excel file), a screenful would be enough, and use that until you get correct operation.

Only then, try the same code with real data; if necessary start looking for optimizations.
Luc Pattyn 16-Mar-22 15:43pm View
Luc Pattyn 15-Mar-22 15:50pm View
?? they asked for employees with department,
plus employees without dep,
plus departments without employees.
So LEFT JOIN can't be the answer.
Luc Pattyn 15-Mar-22 14:55pm View
close, but no cigar...
apparently they also want to see empty departments?!?!
Luc Pattyn 14-Mar-22 6:40am View
Luc Pattyn 14-Mar-22 6:40am View
You're right of course; I forgot about the JavaScript idiosyncrasies.
Luc Pattyn 12-Mar-22 10:59am View
Give him 5, bro.
Luc Pattyn 12-Mar-22 9:09am View
In just 5 minutes you decided you have difficulties doing something you aren't familiar with?
Seems like you didn't bother to study and try at all.
Luc Pattyn 11-Mar-22 12:24pm View
Yeah I always try to give five comments...
Luc Pattyn 10-Mar-22 16:47pm View
Here is one idea for implementation with C# in mind, any language would do:
- you could define a Term class that basically is an array for the states of ALL the variables a,b,c,d (i.e. positive, inverse, or absent) plus something special for always true and always false. I would actually use a List (a stretchable array), I seldom use arrays any more.
- then implement AND operation for Term (with simplification steps 2 and 3 built in)
- then implement a Sum class which just holds zero or more Term objects (again a List) in an OR relationship and knows how to multiply two Sums (with immediate explode).
- define TARGET as a Sum initialized to 1
- then implement the "foreach row" loop performing Sum.Sum all the time.

A whole day should be a luxury...

Luc Pattyn 10-Mar-22 13:16pm View
Now that is clear.
And easy, it tells what is needed and how it can/should be achieved.

They tell you to use Peek (and not EndOfStream) as they want to be able to Read() the offending character themselves.
Luc Pattyn 10-Mar-22 12:46pm View
And now I'm wondering how the first three test cases ever passed, as even the number of method parameters isn't matching ???

Figured it out, the second image defines the job, the first one attempts to solve it.
Luc Pattyn 10-Mar-22 12:43pm View
Thanks for pointing that out.
The OP written specs are wrong again then.
It is getting simpler by the minute, we should only watch for a given value.
So return of the StringBuilder and goodbye IsLetterOrDigit()
Luc Pattyn 10-Mar-22 6:13am View
Four points:
1) you don't need Peek(); it exists so you could create a look-ahead parser, which isn't what you are needing here. Therefore the EndOfStream property is the right way to detect the end of the stream.
2) you rightfully are using char.IsLetterOrDigit, so why would space equals 32 be any relevant?
3) you seem to misunderstand the job at hand; the failing test cases stop scanning the input as soon as a non-letter-or-digit is encountered, something your code does not do at all.
4) You did not provide us with the correct requirements; giving a succeeding case is good, giving a failing case without the expected output isn't.
Luc Pattyn 5-Mar-22 18:01pm View
The first part is preparation, could go in a Form_Load handler or anywhere you see fit. That is the lines:
DataTable dt = new DataTable();
BindingSource bs = new BindingSource();
// here code to load all books in dt
bs.DataSource = dt;
dataGridView1.DataSource = bs;
// now the DGV shows all the books

If you start a filtering by clicking a button, then the remainder belongs in the Button_click handler; that is where you construct your filter (depending on the radio buttons and tthe textbox) and then assign it to bs.Filter property.
Luc Pattyn 3-Mar-22 7:14am View
Luc Pattyn 1-Mar-22 12:48pm View
I don't like overcomplicating things.
If you read "/// proceed with this item" as "yield return item" you're pretty close to what is really going on, the foreach code is being generated by the compiler and the whole thing IS an IEnumerable.
But I'm afraid that is too much information for a first LINQ encounter.
Luc Pattyn 1-Mar-22 12:08pm View
The Where() method IS just an if statement!
Where(someCondition) is equivalent to
foreach(item in IEnumerable) {
    if (!someCondition) continue;
    /// proceed with this item
Luc Pattyn 1-Mar-22 7:59am View
He probably restored those files to his new computer anyway.
And now he is, like many others, wondering why the heck his question popped up high on the list of Quick Answers?
Luc Pattyn 28-Feb-22 10:20am View
Sorry, in the line
IEnumerable<string> stringSequence = numbers.Select(x => strings[x]).ToList();

calling ToList() does not make any sense as you are assigning to stringSequence which is an IEnumerable, and your numbers.Select() already is an IEnumerable, so all memory and CPU cycles spent to ToList() are wasted.

Luc Pattyn 28-Feb-22 8:31am View
I specialize in discarding code, it is a great way of reducing the bug count

Luc Pattyn 14-Feb-22 19:41pm View
you're welcome.
Luc Pattyn 14-Feb-22 19:30pm View
webClient.Headers.Add("user-agent", "hi there");

is sufficient D)
Luc Pattyn 14-Feb-22 19:28pm View
Yep. That seems to work. They didn't get much smarter after all...
Luc Pattyn 14-Feb-22 19:22pm View
They got smarter? (see my other reply)
Luc Pattyn 14-Feb-22 19:21pm View
OK, it is not your code that fails, it is the server. Probably on purpose.

I switched to synchronous download, added a try catch, and dumped the response stream. I don't understand all of it, but I got the impression that they just want to prevent non-human downloads. It would be rather easy to "borrow" all their stuff if they didn't protect somehow.

The only suggestion I can make is: download what you (might) need manually, and store it elsewhere, e.g. as embedded resources within your app, or on your own web server, etc.
Luc Pattyn 14-Feb-22 19:06pm View
I moved my code to .NET5; it worked well for my test file, even without the TLS12 thingy.

I tried your file, it starts well but eventually it fails with a 500.
I'll investigate.
Luc Pattyn 14-Feb-22 18:57pm View
From my observation downloading a file from a secured site (https://... URL): creating an empty file is the first thing it does. When that succeeds it starts trying to contact the site and start the download. Which failed without the TLS12 option, and succeeded with it. The failure was a WebException "request aborted. Could not create SSL/TLS secure channel" which is much more specific than a vague "500. Internal error"

I used .NET FrameWork 4.5 but I can't imagine that matters...

Can you download the file manually i.e. with a browser?
if so, does that need login in?
if so, your code needs to provide credentials

Does the problem also exist with other URLs? Can you show a failing URL?
Luc Pattyn 14-Feb-22 16:49pm View
unfortunately that is not what was asked for, you provided the inverse function!
Luc Pattyn 13-Feb-22 21:14pm View
I was able to replicate.
In my case the download did never take off due to a security issue.
This can be seen in the e.Error field at the Completed handler.
It is all about TLS.
What is needed is executing once a statement like this:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

the latter works on older .NET versions that don't know about Tls12.

I strongly suggest to always provide code that checks the e.Error field in competion handlers (same for BackgroundWorker and many others).

Luc Pattyn 13-Feb-22 20:50pm View
true. Is the empty file timestamped according to your latest try run?

You did not show the code for Progress and Completed handlers.
If anything goes wrong there, the download might come to a standstill right away.
Luc Pattyn 12-Feb-22 23:13pm View
Hi Casper,

I created a MineSweeper program and a little article describing it.
Available here
Luc Pattyn 10-Feb-22 16:11pm View
No no
(1) you don't need an implementation to understand an algorithm. Abstract thinking is required, not implementation and certainly not tools to validate or improve implementation.
(2) You seem to have missed part of the assignment, not only do the numbers have to be monotonic within each line, but also the lines need to be in a specific order, see the n=5 example where 1+1+3 precedes 1+2+2
Luc Pattyn 10-Feb-22 15:21pm View
Sorry, I disagree.
(1) Debuggers can be used to pinpoint coding errors, however debugger sessions don't fix wrong algorithm choices.
(2) Working backwards is the obvious way, however it will not yield the requested order!
Luc Pattyn 10-Feb-22 13:31pm View
when it fails for one or more cases, the algorithm is wrong.
Before you start coding, you should think about the problem, formulate a potential approach and test it manually.

I will not help you any further except for this one hint: when searching all correct summations in the required order you can't solve this by printing before you got a correct sum. Reduce the problem to a slightly smaller one.
Luc Pattyn 10-Feb-22 13:18pm View
can you come up with any value of n for which your code generates the correct output?
did you try n=3? n=5?
Luc Pattyn 10-Feb-22 2:09am View
molte grazie Carlo
Luc Pattyn 10-Feb-22 0:55am View
// that is elementary:
while(wanted>0) {
....calculate random position
....if position isntbomb {

Luc Pattyn 9-Feb-22 22:42pm View
The RHS of Button btn = new Button(); inside displayGrid() is ineffective, as btn gets another value in the next line by calling individualButton().
Overall displayGrid() is acceptable, not perfect.
Floodfill() calling individualButton() is not OK, as that creates a new button for the cell, a button that is not relevant to the user, and later probably gets confused with the original.
One should provide a Control when the user interface needs one, not when calculations seem to be interested in one. As I said, introducing a Cell.Reveal() method would remove the urge of creating extra buttons. And making Cell a descendant of Button would simplify things.
Luc Pattyn 29-Jan-22 17:24pm View
Not sure it wouldbe sufficient, but I would most certainly execute client.DownloadProgressChanged += downloadprogress; before calling DownloadFileAsync
Luc Pattyn 27-Jan-22 20:38pm View
You did not tell us what the problem is.
You most likely didn't show enough code to give us any chance to help you.
You have an empty anchor i.e. <a...> and </a> without text/image in between.
And you certainly have too many </a> tags.
Luc Pattyn 25-Jan-22 1:01am View
there are two cases: one with numbers, one with empty line.
don't try to find numbers once you decided the line is empty!
use if - else
Luc Pattyn 24-Jan-22 17:51pm View
ευχαρίστησή μου
Luc Pattyn 24-Jan-22 15:11pm View
I see; the Hunga Tonga really shook everything up.
Too bad Google isn't accommodating matching code.
Luc Pattyn 24-Jan-22 14:36pm View
I liked the image most of all, mercury/fluid reservoir at the top, and a non-monotonic scale. A truly unique design I'd say.
Luc Pattyn 21-Jan-22 21:42pm View
I guess you are in the following situation:
- using Visual Studio 2022 (no problem)
- targeting .NET 5 or 6 (and not .NET Framework (no problem)
- building with project setting: Build/General/Nullable: enable (is the default) AHA
- and probably: treat warnings as errors (is often a good idea)

Which would mean you're using C# 8.0 which has a new feature (possible null testing) resulting in a warning/error when a reference might be or become null.

Here Console.ReadLine() returns null on end-of-input, and the destination was declared array of string, not array of string? (the ? being the newest thingy indicating you would accept null values).

I haven't investigated yet, I'm not sure how the new feature could be useful, you might consider changing the conditions I mentioned earlier. The most obvious one would be: Nullable: disable
Luc Pattyn 21-Jan-22 18:00pm View
If they must be files, I'd suggest you use the folder returned by Path.GetTempPath (doc)

Putting data files (perm or temp) in or under the EXE folder will fail as soon as the EXE folder is in or under one of the system folders such as "Program Files". (access denied).

You can delete the .mp3 once conversion is done.
You will need a way to figure when playing has finished so you can also delete the .wav file.
Luc Pattyn 21-Jan-22 10:24am View
Thanks Richard.
Luc Pattyn 20-Jan-22 13:32pm View
you're welcome.
Luc Pattyn 20-Jan-22 12:15pm View
your data has property_id = 1 and your query requests property_id = 2 so an empty set is the correct result. If you hope for something else your query isn't appropriate.
Luc Pattyn 20-Jan-22 10:26am View
Your code is assuming:
- both lists have same length
- both lists have same order
- no duplicate items are present within any of these lists

and the OP did not even start to explain when he considers two lists identical or different...
Luc Pattyn 19-Jan-22 23:43pm View
Please make sure the creation and all operations on the notifyIcon occur from the GUI thread; if not, the strangest things can happen (or the most normal things might not).
Luc Pattyn 19-Jan-22 23:27pm View
So you do see the notifyIcon (and your title isn't accurate)?

I've never used ShowBalloonTip, I use Text property to get a simple tooltip.
Luc Pattyn 19-Jan-22 23:11pm View
Sorry to ask, but do you have something like notifyIcon1.Visible = true; anywhere?
Luc Pattyn 18-Jan-22 20:11pm View
if your tokenizer needs spaces, I'd suggest not to care about monadic minus. Simply threat a monadic minus as any other (dyadic) operator, so let it turn "-5" into "- SP 5" the same way it turns "+5" into "+ SP 5".

During the evaluation when you are expecting an operand and you get a minus sign, you only then must realize it is a monadic minus, not a dyadic minus, and act accordingly.
Luc Pattyn 18-Jan-22 18:14pm View
I've never encountered a regex in the implementation of a calculator.
The typical approach is:
1. turn the input into RPN (reverse Polish notation)
2. evaluate what you have using a stack, where you either immediately execute an operator or push it onto the stack depending on precedence.

Obviously step 1 is to be skipped if you are mimicking an RPN calculator (such as HP35).
Luc Pattyn 18-Jan-22 8:49am View
Your code needs error handling, as explained before. Then act on what you get as error message. That is all I can help you with.
Luc Pattyn 18-Jan-22 8:44am View
To get items from the database, you need an SQL statement (SELECT * FROM table) and a while loop; you have done so already. Each iteration of the loop would give you the details of one broodje, which you can use to create a new Item(...) which you add to $items (using the right ID!).

To place an order, it depends on how you see it. One way would be like this:
- add an "Order" button similar to the "Clear All" button;
- and add some code that checks the button is pressed (similar to how the incrment/decrement buttons are handled) and call a new function that iterates all items and inserts the ones with non-zero quantity; it basically is the counterpart of getAllKnownItems(), with an SQL INSERT statement inside the loop.

All of this is basic PHP stuff. My code was meant to show you something that works (and deals with quantities). Use it any way you want, expand it, or drop it. It is your job after all.
Luc Pattyn 18-Jan-22 8:16am View
An insert (or any other) database operation can fail for many reasons.
The execute() function returns a bool indicating success/failure.
When it fails, one should call mysqli_error() to find out the reason of the failure.

And yes I know, most examples google finds don't do error handling on inserts, but that is a big mistake as your experience proves...
Luc Pattyn 17-Jan-22 15:58pm View
you're welcome
Luc Pattyn 17-Jan-22 14:25pm View
(1) I copied one line of yours without noticing it contained a bug (wrong type!); should be
Dim parsedate As String = ComboBox2.SelectedItem.ToString
(2) yes VB uses parentheses, my mistake, I'm used to C# and brackets, so
Dim parsedate As String = ComboBox2.Items(i).ToString
Luc Pattyn 17-Jan-22 9:26am View
1. you did not show how $db got initialized in orderaction.php
2. you don't have any error handling in function insert
Luc Pattyn 16-Jan-22 19:51pm View
You are basically repeating your earlier questions, which this site does not like a bit.

And shame on you. That is not studying. That is begging to be spoon-fed.
Luc Pattyn 16-Jan-22 19:47pm View
You're welcome.
Enjoy your study!
Luc Pattyn 16-Jan-22 19:29pm View
Where ever that declaration applies (in it's "scope") children will represent an ArrayList<treenode> unless it is null (null is not considered an instance of any class). Here children can't represent a string, a collection of pixels, or anything else.

However that line does not create anything at all. It tells the compiler to reserve some memory so a reference to an ArrayList<treenode> can be stored. The instance of ArrayList<treenode> has not been created here, that will take a statement with a new keyword, which would call a constructor etc.

Are you sure you understood the previous lessons of the course you are taking? I would suggest you reread some of the previous chapters...
Luc Pattyn 15-Jan-22 15:32pm View
When backed against say the east wall, moving one step north or south will change the (squared) distance, and at least one of these will be smaller; so you can always improve your position unless at least one of those directions is prohibited (corner or cul-de-sac).

This approach is based on extremely local optimization, which is not guaranteeing the absolute optimum (you might enter a small room without another exit rather than taking a long corridor).

So when the simple approach isn't good enough, you need a more complex algorithm that takes into account much more information.

AFAIK the optimal approach is pretty complex, it would resemble a flood fill: before each step you really execute, you should simulate performing multiple steps (both by you and the enemy) starting from the current positions and going in all possible directions, you avoiding all cells the enemy can reach at the same time or sooner. Stop the simulation (i.e. limit the number of steps simulated) whenever (1) you don't want to calculate any further or (2) no safe cells remain; then pick the safest spot you have found and finally do one real step on the path you used to get there during the simulation.

Warning 1: the slightest mistake in the implementation is bound to put you on an eternal loop, never getting far away from your current positions;

Warning 2: make sure you got the rules correct; do you have to move when the enemy does? does the enemy have to move when you do? etc
Luc Pattyn 12-Jan-22 21:25pm View
3) it is mostly OK the way it is: he needs access to previous and next row/col and did not want to treat edge cells special, so he provided for two extra rows and cols with dummies. However, he forgot to properly initialize them.
Luc Pattyn 3-Jan-22 9:56am View
Why do you accept a solution that does not produce the result you want?
Luc Pattyn 2-Jan-22 18:06pm View
You're welcome.
I'm glad that went swiftly :D
Luc Pattyn 2-Jan-22 17:59pm View
I must admit I never understood your two-constructor setup.
Looking closer, I would expect the Texture(...) line be in the 2-parm constructor, like so:
Texture(resourceId, mipmaps)

and the 1-parm constructor simply calling the 2-parm one.
Luc Pattyn 2-Jan-22 17:42pm View
correction, one last suggestion:
please check context?.getPackageName() where you use it. It should NOT be null!
Luc Pattyn 2-Jan-22 17:25pm View
some ideas:
- do you have a file called "football" inside the "drawable" folder?
- have you tried with a more appropriate filename, with one of the standard image extensions (such as .png)?
- are you using "configuration-specific alternatives"? if so look here ( ) and make sure you also have such file in the default drawable.

Now I ran out of ideas.
Luc Pattyn 2-Jan-22 16:35pm View
FYI: I've added, later modified, a comment to your original question. It's about filenames.
Luc Pattyn 2-Jan-22 15:34pm View
I would expect one (or several) texture files inside the drawable folder, and then a "drawable.myTextureFileName" in your Texture creating statement tex = Texture(...);

EDIT: have been reading some more; my first paragraph seems incorrect now. However, is your texture really called "img" ? rather than a filename with a typical image extension? Maybe try once again, with some .png file or similar.

BTW: when you improve your question (which is OK) you should also reply to an appropriate solution or comment in order to send a signal to others. Just changing the question creates no signal to anyone...
Luc Pattyn 2-Jan-22 15:12pm View
I think we already know why: the very first message said E/com.a3dmodelap: Invalid ID 0x00000000., so what remains to be done is find out why there is a zero ID.
Luc Pattyn 2-Jan-22 13:45pm View
As the error message said 'str' object is not callable I would guess that language pools function and variable names; however I don't need to know for sure, as I would never do that in the first place.
Luc Pattyn 1-Jan-22 13:42pm View
yeah, check capitalization of variables/properties.
Luc Pattyn 1-Jan-22 13:29pm View
you can use it anywhere you want.
For instance, as a replacement of whatever your ToString() method currently contains (then don't forget to make it return hhmm)
Luc Pattyn 30-Dec-21 14:05pm View
Of course, you can't declare a class-level member in the middle of an if statement. Make up your mind, decide what you want, and make sure your indentation matches your intentions, so you don't confuse yourself and others...
Luc Pattyn 30-Dec-21 12:08pm View
Your pi approximations are slightly above, then slightly below, the correct value, as you alternately add/subtract a correction term. So it would be best to keep iterating until said correction becomes irrelevantly small, i.e. less than epsilon, which is a small number that must satisfy the relationship
1.0 + epsilon != 1.0

which means it is still noticeable when using a number representation with finite precision. As double is capable of holding about 15 decimals, epsilon = 10^-12 seems very reasonnable. That would give a pi approximation with some 12 correct digits.

NB: that will take billions of iterations, since denominator only grows by 2 per iteration!
Luc Pattyn 30-Dec-21 11:58am View
Writing the code is your job, not mine.
You're on track; see my suggestion in my previous reply to you.

Luc Pattyn 30-Dec-21 11:30am View
I see one way to improve your code:
rather than asking the user how many iterations he wants (what you erroneously call "accuracy"), you could let the loop continue until the difference drops below a specified tolerance, say 1e-12

It then would be wise not to show all intermediate steps...

Luc Pattyn 30-Dec-21 10:34am View
I think you should remove the comma in
item: item,
Luc Pattyn 29-Dec-21 15:38pm View
You're right Magnus, Application class is a Windows thingy. My mistake.
Fortunately there also is AppDomain.ProcessExit.

Luc Pattyn 26-Dec-21 21:34pm View
I have zero experience with this. However I would try TypeConverter(typeof(BooleanConverter)) for CheckerStates

If TypeConverter(typeof(StringConverter)) works for a StringCollection, I would expect a BooleanConverter to work for a Collection[bool>
Luc Pattyn 26-Dec-21 10:26am View

if/when you get a solution to your problem, please be so kind and publish it here, to the benefit of others who may have a similar problem.

Thanks in advance.
Luc Pattyn 22-Dec-21 13:35pm View
very. Lots of peripherals use the request-resonse paradigm and will send a result almost immediately when told to do so. For those, all threading stuff is overkill.
Luc Pattyn 21-Dec-21 17:18pm View
in everything you posted $role appears only once, that cannot be correct.
Luc Pattyn 21-Dec-21 15:46pm View
now see added2 (the circle is round)
Luc Pattyn 21-Dec-21 14:59pm View
You're right.

I've added an alternative to my original post. It is however obsolete, and also limited to .wav files.

Working on something new...

BTW: a decent mp3-to-wav converter can be found here
Luc Pattyn 14-Dec-21 16:34pm View
A footer belongs inside the body; and there is a footer tag in modern HTML.
See tag_footer
Luc Pattyn 11-Dec-21 19:23pm View
You're welcome.

Becoming proficient at software development takes time. If it is all new to you, I recommend a real book for studying a first language. Just read all of it from page 1 for say one week. Read a chapter, then do the given exercises; rinse and repeat. You might skip the chapters you're not interested in (e.g. graphics, web, ...). After a year, read it again.

Microsoft books seem to be fine, e.g. the ones by Petzold on C#.
O'Reilly is good too. I own the second edition (2006) of their "Learning PHP & MySQL" by Davis & Phillips, I think that was my home base back then for web stuff. Yes both PHP and MySQL have evolved since, and the book hasn't AFAIK, but even today I'd rather spend a week studying the book than watching cheap and anonymous Youtube video's.

If your first language (hopefully a strongly typed, well structured one) is sufficiently understood, extra languages can be learned from an e-book in a matter of a few evenings, as it mainly is getting to know new syntax for known concepts.

However, programming is about much more than languages, and that takes practice, experience, hence time. No book recommendations, however you might want to read some excellent articles here on CodeProject; make sure you only pick ones with lots of high votes and/or authors with good reputation score. Look for design aspects, best practices, and look at their code!

Luc Pattyn 11-Dec-21 16:01pm View
1. I don't see anything wrong about products needing/not needing quotes, so I have no clue as to what you mean.

Testing whether $_POST exists is a bad hack; I don't see why you wouldn't do it the proper way.

I've told you to give your button a name, and test for that name to appear in the $_POST array. I told you twice. Why don't you take good advice? Did you try print_r?

"It works" does not imply it is any good. Do you want to drive a car that needs service every other day? If you want reliability, then apply good practices, and avoid all hacks.

I bet your database table already contains several empty rows (all five fields empty, ID auto-incrementing). The less strict you make your tests (=your defense), the more garbage you will collect.

In the mean time, I looked at your earlier question about passwords, and was surprised to see how you had a first, not so good, attempt to defend against SQL injection and somehow found the correct way to handle it. But then, you don't do anything about it today?????
Luc Pattyn 11-Dec-21 15:09pm View
Most coding videos are crap, and watching them is a big waste of time.

I just performed a simple test: a submit button without a name doesn't put anything in the $_GET or $_POST array. Add a name attribute (e.g. name='btnInsert'), as I said earlier.

The print_r function (click here!) shows the contents of its first parameter, so you can use


to see everything that gets passed to your page when a POST action occurs. It will show the textbox contents and whatever the submit adds to it.
Luc Pattyn 29-Nov-21 0:15am View
You're welcome.

BTW: input isn't a thing, it is just the name I have chosen for the string variable that I'm using to hold whatever the user types. Don't be afraid of using variables, and please give them meaningful names.
Luc Pattyn 13-Nov-21 16:22pm View
Two suggestions:

1. echo all three variables ($isbn, $author, $title) right before the bind_param statement.

2. as an experiment, change the order of the fields e.g. swap isbn and author (in field list and in bind_param) and see what that gives,
Luc Pattyn 3-Nov-21 17:37pm View
OK, I turned my test code into a complete app and now I can see what you were trying to explain. It seems whatever Control gets added below y=32767 gets stuck at that depth. Tested for PictureBoxes and Panels.

It must be one the quirks of the very oldGDI+ graphics library, upon which all of WinForms is based.

Well, it probably isn't a good idea to create virtual forms that are hundreds of screen heights tall anyway. I don'tknow whether WPF does any better, it might.

You may reconsider your user interface, showing less information at any point in time. That is the normal approach, sparing a lot of scrolling...
Luc Pattyn 3-Nov-21 16:44pm View
You'll need to explain in more detail, or better yet, show relevant code.
Luc Pattyn 3-Nov-21 16:20pm View
ints have grown up many years ago: int.MaxValue does not equal 32767, and ScrollProperties.Maximum isn't limited to 32767 either.

PS: good luck with your enormous number of gifs...
Luc Pattyn 22-Oct-21 12:53pm View
Hi Bill, not sure what you are referring to. I did test my code before I published it, it worked satisfactorily (except maybe that terminating it is a bit hard). And in the mean time the OP accepted the solution.

Luc Pattyn 22-Oct-21 1:55am View
Sorry, I did see your solution, found it hard to read and failed to grasp it. I did come up with a clean approach which I will offer as a solution in a moment.
Luc Pattyn 22-Oct-21 1:37am View
Yes every PB will be disposed of, however they also have been added to the Form.Controls collection (and never removed), so I expect them to be alive and invalid, i.e. all but the most recent one which hasn't been disposed of yet.

However, the problem lies elsewhere. I'm still working on it and will report to the OP when ready.
Luc Pattyn 21-Oct-21 23:33pm View
Yes I did; I also added a comment to the OP.
Luc Pattyn 21-Oct-21 23:33pm View
My main point is: as you only want one PB at a time, you only need a single one: just create one, add it to the Form.Controls collection, then start your loop that feeds images to it, one by one, with delay. A new image does not need a new PB.
Luc Pattyn 21-Oct-21 23:12pm View
why are you creating all those PictureBoxes? Couldn't you just use a single one?

Or even none at all (you can Paint to the Form directly, or give it a BackgroundImage).
Luc Pattyn 21-Oct-21 23:10pm View
Actually a lot of PB get created and disposed of, however they all get added to the Form.Controls collection which doesn't look quite right (although there is some built-in mechanism that might remove them on dispose, can't remember tthe details as I don't ever write code in that way).

What could be the reason to use different PB all the time??
Luc Pattyn 19-Oct-21 14:12pm View
the links are OK, what they refer to is valid in general, however IMO not relevant to the question at hand.
I don't know any future CP member, do you? :D

Luc Pattyn 19-Oct-21 13:32pm View
"Any serious C# timing should be using GC.Collect, and warm-up runs to factor out JIT costs."
That may be very true for complex applications, however for the problem at hand it is not IMO, as the code is highly numeric and only a handful of objects are created at all (a few strings reporting results).
Luc Pattyn 19-Oct-21 12:13pm View
I've added some info at the end of my "solution 1" above
Luc Pattyn 18-Oct-21 17:48pm View
Hi Bill, I never stopped visiting the site, however I only occasionally participate as the words fail me to politely describe the average quality and involvement of the questions posted.

Luc Pattyn 18-Oct-21 11:14am View
Quick Answers it is :D
Luc Pattyn 16-Oct-21 21:02pm View
Sounds good; it didn't exist in my K&R years; learning something new every day...
Luc Pattyn 28-Sep-21 10:12am View
Very strange. What is this instrument? And can you provide a link to that manual?

Assuming their statement is correct, you should set TerminationCharacter to CR, enable the use of TerminationCharacter on writes, and just hope the answer will also end on CR. Try it!
Luc Pattyn 28-Sep-21 8:27am View
That is confusing, first you said "my instrument needs a carriage return" and now you imply an EOI is needed. It should be one or the other, not both.
Luc Pattyn 31-Aug-21 11:30am View
The built-in Array.Sort() method sorts the array, which means it rearranges the content of the array according to the result of the comparer given to it; everything you need has been shown, it is just one method plus two lines of code!
Luc Pattyn 31-Aug-21 7:57am View
you might simplify that using String.ToCharArray()...

Luc Pattyn 25-Aug-21 7:08am View
you're welcome
Luc Pattyn 14-Feb-21 10:20am View
You're still using DateDiff where there is no need for it, you can calculate MinDOB and MaxDOB in VB.NET as I showed you, then just use SQL to compare Age to those limits.

Your query has multiple problems (missing space, incorrect use of BETWEEN).
I suggest you build your query string into a variable and have a look at it before you feed it to the database.

Also, you should put all of it inside a try=catch and look at the exception when you get one.

Luc Pattyn 13-Feb-21 15:35pm View
I don't know any object that has both a num_rows property and a fetch_assoc() method. Yet you have $sonuc do both?????????????
Luc Pattyn 13-Feb-21 15:30pm View
The change seems necessary and good, but insufficient.

I have some trouble understanding your code, it seems more complex than is needed. I mostly distrust your expression yielding the children. I'm not convinced rootitem is needed at all.

I'm used to enumerate files in a hierarchical file system, and that basically
goes like so (in a C#-like pseudo-code), starting with an empty result:

public static void AddAllFiles(List result, string folder) {
var entries=Directory.GetDirectoryEntries(folder); // both files and folders
foreach(DirectoryEntry de in entries) {
if (de.IsFile) result.Add(de);
else AddAllFiles(result, de.Name); // if is folder

So there is no special treatment of the first entry, no rootitem.

Suggestion: increase observability, do whatever it takes to see what is actually going on. There are basically two ways to do that:
1. use logging (add print statements documenting the steps (i.e. adding to result, recursing, ...)
2. use the debugger.

For a lot of problems, including this one, I prefer logging, as that results in an organized report of what went on, whereas debugging shows only snapshots (like a frame-by-frame movie).
Luc Pattyn 13-Feb-21 14:10pm View
Count me out. It sounds much like a new virus vector...
There is a reason why autorun was turned off for flash drives and the like!
Luc Pattyn 13-Feb-21 13:03pm View
I tend to make people think, and hopefully learn...

Luc Pattyn 13-Feb-21 8:06am View
You haven't told us what the data types are (in database and in code).
My best guess would be OrderNo is a numeric field, intended to hold an order number; so
cmd.Parameters.AddWithValue("@OrderNo", txtOrder_No.Text);

is not OK, as you are providing a string.
If so, use int.TryParse() to convert your textbox(?) content to a number.

Luc Pattyn 11-Feb-21 21:25pm View
So overlap is allowed; how could it result in a lower minimum??? I don't see a need for an overlap.

Some test cases fail? Then give us one of those!
Luc Pattyn 11-Feb-21 8:10am View
I'm a duct tape expert after all. :D
Luc Pattyn 9-Feb-21 13:13pm View
All whitespace gets accumulated and replaced by a single space, that is a feature of HTML. There are four ways to avoid it:
1. use PRE tags as Richard pointed out
2. use &nbsp; instead of a space (i.e. modify the source)
3. don't use HTML
4. don't ever put two or more spaces in a filename (I tend to avoid any space in filenames!)

BTW: why would your tool need to use the result of HTML; the HTML source itself contains the double spaces, so parse that, using the HTMLutility pack or something similar.

Luc Pattyn 9-Feb-21 12:19pm View
You can't loop HTML code like that, put all the loop stuff inside PHP, like so (using period to concatenate strings, and semicolon to terminate PHP instructions):

foreach ($files as $file) {
echo "<tr>";
echo "<td>".$file['id']."</td>";
echo "<td>".$file['name']."</td>";
echo "</tr>";

Luc Pattyn 8-Feb-21 22:00pm View
Your specs are incomplete:
- if your program is ran twice, should it generate the same series of results, or not?
- if your program would have a second for loop, identical to the one already present, should the second loop generate the same series of results, or not?

And is there some upper bound to the number of values involved, i.e. what is max(to-from) ?

Luc Pattyn 8-Feb-21 20:53pm View
No need to repeat your question. If you want to expand or correct your question here, simply click "Improve question" and edit...

Luc Pattyn 8-Feb-21 20:42pm View
Maybe the matrix could be organized as a collection/array of columns, rather than a collection/array of rows?

You might get a more tailored answer if you were to provide more context: what is the overall application about, what libraries or operations are involved, why would you want to move columns around, etc...

Luc Pattyn 7-Feb-21 21:54pm View
When the available methods don't satisfy your requirements, you'll have to create your own. I would suggest you use Directory.EnumerateFiles, and for each file returned, you check its existence in the destination, and copy when appropriate using File.Copy.

Beware, whatever I/O methods you use, you should always set up a try-catch construct and handle possible Exceptions (at least log or display the entire Exception.ToString() result). Doing so would also have indicated why FileSystem.CopyDirectory didn't perform what you expected.

Finally, file path operations are best handled by the Path class; e.g. its Path.Combine method is quite useful.

PS: the FileSystem class is rather VB.NET specific, the classes and methods mentioned above are more general, they are the normal way to do file I/O in C#, but work equally well in VB.NET; anyway, you may have to read up some more...
Luc Pattyn 7-Feb-21 21:06pm View
The third parameter is a boolean flag named overwrite; you pass True and complain files get overwritten. Have you tried setting it False?

Luc Pattyn 7-Feb-21 17:33pm View
Sunflower seeds? Did you run out of kopi luwak? And they didn't notice?
Luc Pattyn 7-Feb-21 17:18pm View
There's only a few episodes per series, and they keep importing ex-wives, forgotten siblings, tourists, fresh nobility, strange cultists, and more potential victims, so Midsomer is doing well actually.

Top Expert? that is hard to believe, I only answer a few questions, I tend to pick the ones that I know something about AND show some potential. Which doesn't add up much. So I was quite surprised a few weeks ago when I received an email announcing another MVPship... Things must go really badly.

But you Sir, you're a rock.

Luc Pattyn 7-Feb-21 16:44pm View
If you're not sure it can be done, how can you even begin to hope you could do it???
Luc Pattyn 7-Feb-21 16:18pm View
That's Tom Barnaby's twin brother, isn't he?
Luc Pattyn 7-Feb-21 15:50pm View
I dunno.
The one that encourages reflection?
The one that interrupts and spoon feeds?
The one that provokes a non-stock reply?
Luc Pattyn 7-Feb-21 14:49pm View
+5 good cop bad cop routine often works wonders...

Luc Pattyn 7-Feb-21 12:29pm View
May I suggest more facts and less think. :D
Luc Pattyn 7-Feb-21 12:09pm View
If by "picture element" you mean a PictureBox, I would advise against that silly Control; just use a Panel and draw its content yourself.

I hope you measured the time your library takes to analyse a single picture.

And as long as you work frame by frame, this is a situation where you absolutely must pipeline the whole process; which means using threads and proper synchronisation.

Finally, there are lots of nice articles on CodeProject, maybe you'll like some of these.

Luc Pattyn 7-Feb-21 11:56am View
IMO the deletion query should use the same WHERE clause as the discovery query, hence selector, no email.

Your second $stmt->execute() belongs inside the if($stmt = $pdo->prepare($sql)) block.

Your fix is not good. The problem may have disappeared, the code is not OK.
As Richard pointed out, datetime values in a database should use the appropriate type. Strings are for arbitrary text, a datetime is a very structured thing; a database knows how to compare datetimes; whereas string comparison does not understand e.g. month names.

With a datetime field, you could replace most all of your code with a single query, saying delete all records where code and selector match AND expires is less than NOW.

Luc Pattyn 3-Feb-21 10:05am View
You don't need the value of 99999999! to determine how many digits it would have; all you need is its logarithm, say in base 10. And taking the logarithm of a product boils down to summing the logarithms of its factors, whether you apply it to the definition of factorial, or to the Stirling formula...

Something like this
public int calcNumDigits(int max) {
double numDigits = 0;
for (int i = 0; i < max; i++) {
numDigits += Math.Log10(i+1);
log("" + max + "! has " + numDigits + " digits");
return (int)Math.Ceiling(numDigits);
suffices to get to the result: 756570548 decimal digits.
Luc Pattyn 3-Feb-21 10:01am View
I'm glad your calculator is happy.
BTW the logarithm of a product equals the sum of the logarithms of its factors.

Luc Pattyn 3-Feb-21 9:59am View
Indeed 99,999,999! has some 756570548 decimal digits.
You could store it as a string, consuming 756MB (C) or 1512MB (C#) of memory; or as an int32 array with 6 digits per int, requiring some 500MB of memory.
I don't see a problem.

Luc Pattyn 2-Feb-21 21:00pm View
Some kind of BigInteger scheme is being used, built as an array of ints where 4 (actually 6) digits of the big number are stored in each element. So it works like a base 10,000 (actually base 1,000,000) representation of integers with arbitrary range, assuming MAX is chosen appropriately.

Luc Pattyn 17-Jan-21 8:20am View
Luc Pattyn 14-Jan-21 22:09pm View
Did you check what is inside your query string?
Is Year a numeric or a textual field? and Section?
Why do you have a ";" in the one query and not in the other?

suggestion: as long as it doesn't work, add a textbox (or label) that permanently displays your query string and set it before you execute the query. Make sure to use a monospaced font such as Courier New.
Luc Pattyn 14-Jan-21 6:04am View
Luc Pattyn 10-Jan-21 16:49pm View
Excellent answer, the only one mentioning stack.

How about a compiler option to automatically nullify all references that go out of scope?

Luc Pattyn 10-Jan-21 9:08am View
When all objects are different and have a predetermined destination, the situation is completely different. Whatever their number I would keep a current position Pi and a destination position Di for each of them, and then minimize the function SUM((Pi-Di)*(Pi-Di)).

Remark: in general you can choose many different improvement or cost functions, and many of them will work well assuming they indeed yield an extreme value (minimum or maximum) on the ideal solution AND hopefully tend to monotonically evolve towards that extreme as your system nears the state you're after. A sum of squares is known to be pretty good in most cases.

Luc Pattyn 6-Jan-21 17:56pm View
That looks like a wandering bracket; be careful, they tend to be dangerous.
Luc Pattyn 6-Jan-21 12:11pm View
Your instance of big class holds an array of type normal, whoch gets dimensioned to 10 (i.e. 10 times a null pointer) but not initialized to real objects as you did not call setup_big() at all.

You must either call setup_big() inside your Main method, or better call it inside a constructor of the big class.

Luc Pattyn 6-Jan-21 12:06pm View
If you created, positioned, and supplied properties to the form and the ZComboBoxes by the Visual Designer, then it is a mistake to immediately replace those ZComboBoxes with new ones, which will have default properties (such as Location zero,zero) independent of what you did while using Visual Designer.

Luc Pattyn 27-Sep-20 20:11pm View
It is rather hard to create a triangle having two but not three sides with zero length...
Luc Pattyn 4-Sep-20 19:21pm View
That is horrible code.

1) whoever stores passwords as plain text should be fired right away.

2) for a single login, you think it is wise to read all known users from the database?

3) You don't need DataAdapters and DataTables for a simple read.

4) Objects that have a Dispose() method should be disposed of when done e.g. SqlConnection.

5) why would the user attempting to log in happen to be in the first row???
Luc Pattyn 4-Sep-20 19:08pm View
Thanks for your code. Do you have a question?

I do: If you happen to get such an exception, what is it your program is doing at that point? Are you killing a thread, closing the port, exiting the program, or what?
Luc Pattyn 14-Aug-20 5:54am View

ignoring exceptions like that is a horrible idea. They offer the first clue when things go terribly wrong, so always make sure you see them.
Luc Pattyn 12-Aug-20 18:26pm View
I disagree, he only wants 10 different results from the random function, the array holds 10 cells and 11 walls surrounding those 10 cells.

It is his comment that is confusing, should have been
return (rand() % 10) * 2 + 1;   // return an odd random number in [1,19]
Luc Pattyn 12-Aug-20 18:02pm View
IMHO it would be easier to keep the logic and the display of the game separate.

In the logic, you have an array of cells, each having only a few possible states; you could model that with an array of integers.

When displaying, you would then have to iterate that array and build a string from substrings (" | " and "*").

And if you use (a) some constants/defines and (b) bracket-style array accesses, everything becomes much more readable. as in:

#define EMPTY 0#define STAR 1#define BAR 2#define CELLCOUNT 10int array[2*CELLCOUNT+1];char mystring[4*CELLCOUNT];for(int i=0; i<=CELLCOUNT ; i++) array[2*i]=BAR;
for(int i=0; i<CELLCOUNT ; i++) array[2*i+1]=EMPTY;array[1]=STAR;mystring[0]=0;for(int i=0; i<2*CELLCOUNT+1; i++){    switch(array[i]) {        case BAR:            strcat(mystring, " | ");            break;        case STAR:            strcat(mystring, "*");            break;        case EMPTY:            strcat(mystring, " ");            break;    }}
Luc Pattyn 11-Aug-20 8:05am View
Your formulation of the problem is quite unclear.

1. You display a number of items, please explain what they are. You work with checked items, what are those? and while removing, you remove the items form the display. What does that mean?

2. It is unclear which items get shown, and which gets checked. Especially how that differs between your first and second run of the program.

3. It would help if you described an actual scenario, such as: initial list contains A,B,C,D with B and C checked, then I ... etc.

4. You show a single method, which first adds items to the database and then removes the same items. What purpose would that serve? and how would that support your statment about deletion in a second run, as there is no code shown that only tries to delete...

5. It would help if you were to show real code.

6. As Garth already mentioned, you are ignoring the return value of ExecuteNonQuery. I would suggest you:
- count and display the number of checked items
- accumulate the return values of ExecuteNonQuery while adding, and display that
- accumulate the return values of ExecuteNonQuery while attempting to delete, and display that number.
- and NOT display every single item you try to delete.
That way you should see only a few numbers, and they should all match; when they don't, you get a first hint as to what is wrong.

7. If adding such observability isn't sufficient, now is the time to start using the debugger.

8. Finally I have several comments on your coding; these probably won't affect the program behavior but improvement is welcome:
- there is no need to open and close the connection for each iteration in a foreach loop;
- code looks much nicer if you apply a using statement for objects that need being disposed of when done, such as your connection.
- I don't like your OfType<string>().ToArray() trick allowing you to remove items while still enumerating the checked items. A simple .ToList() should be sufficient; personally I do this with an extra foreach and an intermediate list, think things-to-remove-after-foreach-is-done. That takes a bit more code but is clearer.
Luc Pattyn 11-Aug-20 5:16am View
Brutally honest? you're way too kind, another career path would be advisable.
Luc Pattyn 29-Jul-20 7:35am View
Thanks, you improved your solution so much I had to five it

Luc Pattyn 28-Jul-20 17:27pm View
Yeah, I avoid this QA section as much as I can, i.e. I read stuff here but I avoid getting in myself; that is, until something pops up that really interests me or puzzles me. And then I try to gain some insight in what is being discussed, which often is hard...

Multiple screens triggers a number of questions (last time I did that is maybe 20 years ago):
1. how do you get your app to automatically start on the screen of your choice? (if you have to move it around manually the shown handler code wouldn't be much help, would it?)
2. if, in the code you've shown, the Form ("this") initially isn't flush left, wouldn't setting its width to screen.width make it extend beyond its screen, flowing into the next screen if any? unless you also do Left=screen.Left; of course...
3. and if you somehow took precautions to get it flush left from the start, couldn't you apply the same trick to also get the width correct immediately, rather than fixing it once shown?

Luc Pattyn 28-Jul-20 13:55pm View
Hi OG, I'm a bit surprised you do this in the Shown event handler, as this would result in a second layout (recalculating docks, anchors, etc) and a visible size change.

I tend to do such things in the Forms constructor, right after calling InitializeComponents; and typically based on SystemInformation.WorkingArea

This has served me well, BTW my systems are single screen, maybe you are handling it differently in order to support multiple screens?

Luc Pattyn 24-Jul-20 10:21am View
A square root inside a simple comparison typically can be replaced by a single multiplication. Yes, this results in many more multiplications but these are very cheap, I've never seen the float/double approach be faster than the pure integer approach, but feel free to prove me wrong...

PS: most numbers aren't prime; the inner loop will most often end with a small divisor (2, 3, 5 or 7), long before the square root has been amortized...

PS2: and IF one needs sequential square roots, their values are known to be rising monotonically, more specifically each square root equals the previous one plus either zero or one, no need to calculate them from scratch each time...

Luc Pattyn 8-Jul-20 12:26pm View
Yes I know, I also see comments and replies come and go all the time. I'm giving up on this Q&A department. I didn't like it in the past, decided to give it another go now, and arrived at the same conclusion.

Goodbye to you all.
Luc Pattyn 8-Jul-20 12:12pm View
As I said before, look at the RTF specification and experiment.
Google brought me this showing there are many possibilities (as always with anything Microsoft) and the story never ends.
Luc Pattyn 8-Jul-20 11:14am View
OK I suggest you start reading this.

And then you will have to manipulate the rtf string (Text property); you either need to locate, read and fully understand the RTF specification document, or experiment with a few RTF documents you create yourself using WordPad (avoid Word if you can, it always generates a ton of code! Unless you have to support that too...).

I once wrote code that adds an image to an RTF document; it used a Bitmap and some native code to get that converted to MetaFile. I don't have the code for the way back.
Luc Pattyn 8-Jul-20 10:17am View
What do you mean by "YouTube"?
Oh, is that the teen version of "TikTok"?

Actually a parrot clip would fit well on the page you referred to...
Luc Pattyn 8-Jul-20 10:05am View
I suggest you run your code on a screen that shows a large (background) image, so you can see which (wrong) part of the screen you are actually capturing; that would make it a lot easier to figure out in what way your coordinate manipulations are failing...
Luc Pattyn 8-Jul-20 10:00am View
great link
Luc Pattyn 7-Jul-20 22:38pm View

I don't speak Python, but my Google foo is OK.
I was able to find this example which looks rather similar to your code.

There are some differences in parameter handling: they don't have any **kwargs (I don't understand what that is doing in your code), and the __init__ of derived classes calls super().__init__(...) which seems quite logical.

Hope this helps.
Luc Pattyn 7-Jul-20 19:21pm View
if you want an unmodified opencv, then pre-built libraries seem to be the way to go: see here.
Luc Pattyn 7-Jul-20 19:07pm View
I suggest you read the articles I referred, and if they don't help (I didn't check them) apply some more google foo.

There must be ready-to-use libraries for Windows, have a look here.

The alternative is to create a new project yourself, inside VS, and then add every source file to the project, by right-clicking the project in the "Solution Explorer" and choosing "Add"/probably "Existing Item". That could be hard if you have more than a few files though.
Luc Pattyn 7-Jul-20 18:50pm View
You should try File/Add/Existing Project
That would allow you to add an existing Visual Studio project.
If the new project stems from an older VS, it will ask you if it can update the project; if the new project is newer than VS, it will probably refuse to do it.

If your project isn't built with Visual Studio, it would probably not work in general. However for opencv you should look around, maybe this article or this CodeProject article helps.
Luc Pattyn 7-Jul-20 15:48pm View
Maybe not everything can or should be solved in a single line of code.

This article will show you a possible way: JSON APIs.

Luc Pattyn 7-Jul-20 11:13am View
Why do you insist on calling it an array, you said yourself it did not start with a bracket.
Do you know at all what JSON is? did you read the documentation on json_decode?
do some research, till you do I will not answer anymore.
Luc Pattyn 7-Jul-20 11:02am View
This was your fifth question.
Each and every time "what I have tried" was answered by something along the line of "Searched in google but didn't find a solution to the problem"

You show no code, no error messages, nothing. No sign of you really trying anything.

And now, you tell me the code I gave you, or some variant thereof, "works". What I want to hear is you did some research and now understand why and how it works. Then you would have made some progress, and be better prepared to answer your own questions...

If you are new to programming, or new to a language or some specific aspect of software, then start by reading some chapters in a book on the subject. Make an effort, try to learn. We are not here to spoon feed you.

Good luck.
Luc Pattyn 6-Jul-20 17:53pm View
I agree, when I encounter a "smart" input field, I run away full speed.

I don't want someone/something changing what I type, and certainly not while I'm typing.

And how about I try to correct a typo and hit backspace/delete? Do I have to take into account spaces or other delimiters I never entered? It is all horrible.

Format AFTER input not during.
Luc Pattyn 4-Jul-20 12:57pm View
Well, the let-us-do-your-homework service is making good use of CodeProject!
So we do the work, they cash in.

And I'm not sure I'll be here much longer, the average level of question content, clarity, and effort are more disconcerting than ever...

BTW: I think I have a code gem that solves Jane's phone number problem; I will wait a month or so before publishing it here.
Luc Pattyn 4-Jul-20 12:25pm View
At least he is honest about it...
Luc Pattyn 4-Jul-20 12:01pm View
you're welcome
Luc Pattyn 3-Jul-20 0:03am View
Did you run your code? with different inputs?
did you carefully read the assignment? did you fulfill all requirements?
Luc Pattyn 2-Jul-20 22:15pm View
Yep. I'm still somewhat active here, more on C# forum though.
Luc Pattyn 2-Jul-20 20:34pm View
FYI: I recently learned Windows 10 does it differently: the taskbar icon does not depend on the application icon, instead it matches the one in the currently active form.
Luc Pattyn 1-Jul-20 16:06pm View
You could start by getting hold of the document that specifies the requirements in the country of interest... Each specification in such document will require you to perform some operations on the image and then get a go/nogo result.
Luc Pattyn 30-Jun-20 14:47pm View
I suggest you read what MSDN says about Enum.Parse, the official documentation page includes an example. Learn something new every day...
Luc Pattyn 30-Jun-20 11:43am View

That is quite original. Not sure what your intentions are, I am sure there is a better way of getting there.
Luc Pattyn 29-Jun-20 17:31pm View
1. I don't understand your code. There is a rather early
and a dozen lines below that I see
receiptds = new ReportDataSource("DataSet1", dc.Tables["dtSold"]);

2. I strongly recommend you apply nested using statements for everything disposable (conn, cmd, ds, whatever) so everything gets scoped properly and gets disposed of automatically at the right moment.

Luc Pattyn 28-Jun-20 14:44pm View
You're welcome.

Performing an operation on all controls of a certain type is doable with a foreach loop on Controls, something like:
foreach (Control c in Controls) {
    Button b=c as Button;
    if (b!=null) b.SomeProperty=SomeValue;

If your form is somewhat hierarchical, e.g. some Buttons are located inside a container (such as a Panel) then in general you need recursion to handle that.

Luc Pattyn 28-Jun-20 13:16pm View
Indeed, something seems wrong.
The BackColor properties are fine, it is only the way the "modified" buttons are painted that deviates. Also the hover color is way off.
And it misbehaves with or without VisualStyles enabled. ???
And it is the same with good old VS2008...
And also on Win7

One way to get rid of it is to select FlatStyle.System (by default buttons are FlatStyle.Standard) whatever all that might mean.
Luc Pattyn 23-Jun-20 9:48am View
so you changed something, did not tell us what, and got a new error.
Maybe you 'fixed' what was correct?
Do you actually know PHP at all?
Be precise, show code (with linenumbers; your original post got edited so you can see how that is done) and tell us its behavior.
Luc Pattyn 22-Jun-20 20:32pm View
That would work for any form, as long as you put a single line in its constructor (or its Load handler):

Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location)

which basically says: set this form's icon to the icon associated with the file whose path I'm giving you, which is actually your own EXE path. Extracting an icon that way is rather expensive.

Two ways to improve:

1. a simpler line would be

Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath)

which avoids reflection but still scrutinizes the file looking for the app icon.

2. If you set both app icon and mainform icon to the icon you want then it is easy and inexpensive to copy that icon from mainform to any other form within the app.

And that is what I usually do by defining a "BaseForm" that holds all my form preferences (sizing behavior, icon, styles, ...) from which I inherit all other forms.


PS: I hope you found in one of the older replies my confirmation on older Windows versions always showing the app icon in the taskbar.
Luc Pattyn 22-Jun-20 17:20pm View
I think so; I used to store my icons and the like in the top folder of the project; a few years ago, I switched to putting such things in the Resources folder, even when I don't always use them as real resources, in the sense of

Assembly assembly=Assembly.GetEntryAssembly();
using (Stream myStream=assembly.GetManifestResourceStream(resourceName)) {
Luc Pattyn 22-Jun-20 17:09pm View
I'm getting a feeling Windows behavior has changed, probably with Win10 (but could be earlier, I never noticed it because I always use the same icon everywhere in an app).

It now seems the taskbar will show the icon it finds in the active form (Main Form, or an open Modal Dialog), which surely makes sense, as it will depend on which form/dialog is open.

The app's icon remains relevant e.g. when you create a desktop shortcut to your EXE.


I created a small test app with a main form and a dialog; app, mainform and dialog all using different icons. On Win7, desktop and taskbar always show app icon. On Win10, desktop shows app icon, taskbar shows icon of active form, i.e. first mainform, then when I open the dialog taskbar shows the dialog icon.

Luc Pattyn 22-Jun-20 16:58pm View
The icon I'm using today can currently be found on my website:

You can download it using "Save image" or whatever it is called in your browser.
Luc Pattyn 22-Jun-20 16:46pm View
Don't ask me why Microsoft did what they did, I don't know, I'm not sure they do either. :)

The way I go about that is: use Visual Studio, open a Form in View Designer, then choose properties, and one by one toggle everything boolean and watch what happens.

One of the strangest things in Windows land is they provide a lot of documentation in textual form but most often refuse to provide images that would make things much clearer. Well, in the end you learn to live with the way it is...

Luc Pattyn 22-Jun-20 16:42pm View
Icons have always been a bit tricky. They evolved from a single image to a set of different sizes and color depths. The one used by the taskbar button will be different from the one used by the desktop Explorer (which itself depends on some choices about icon sizes on the desktop) etc.

I tend to provide an icon file that only holds a 32*32 pixel icon and I use it for both the forms (in WinForms) and the apps, normally that works well for me. If you feel a need to stuff multiple sizes/depths in one ico, make very sure they all look pretty much the same, or you will be in for surprises. What you certainly should not do is take an existing ico and replace one of its images but not all of them.

AFAIK the folder the ico file is in does not really matter; what may be relevant is the properties you give that ico file in Solution Explorer; I tend to use either "content" or "embedded resource" (Not sure what it all means for icons), and "do not copy".

Suggestion: try a few things, if all else fails try again with an icon file from a different source.