Click here to Skip to main content
15,072,311 members

Comments by Philippe Mori (Top 200 by date)

Philippe Mori 25-Jun-17 7:45am View
Standard auto_ptr class has known problems... so your code based on its implementation. If you have a modern C++ compiler, better to use unique_ptr or shared_ptr instead.
Philippe Mori 25-Jun-17 7:42am View
PostThreadMessage is one mean of communication amoung others... Usually, it means that the receiving thread is the UI thread although you can also create an invisible window for that purpose. However, in your case maybe another mean of communication might be more appropriate but we cannot know without having an idea of what kind of interaction is need between those threads.
Philippe Mori 25-Jun-17 7:38am View
Don't use C style cast. Here you should use static_cast.
Philippe Mori 25-Jun-17 7:28am View
Learn C++ and multithreading. You have to understand the lifetime of an object. For example, your Create function timer is local to the function. Without such basic knowledge, you should not attempt to do multithreading... as you need to understand what you do first....
Philippe Mori 23-Jun-17 10:17am View
Your question is not clear... If you want to translate the code to C# code then Solution 1 is the way to go. If the code above is what you have tried so far to interop between C# and C++, then you need to explain your problem. Also, in practice the best solution depends a lot on the actual C++ code as you many options (port code to C#, P/Invoke and mixed-mode C++ to name a few).
Philippe Mori 29-May-17 21:37pm View
If you are not able to understand a tutorial where someone that a lot of time to properly explain it, how do you expect that with an imprecise question, you would magically understand them. Learning take a lot of effort. Read books as other have done.
Philippe Mori 15-May-17 20:09pm View
If you manually add an handler in FitnessFunction, then you have to remove it when not needed anymore and ensure that you won't attach the handler multiple times if that function is called more than once.
Philippe Mori 15-May-17 20:06pm View
The easy way to solve the problem is to call ReportProgress with a user object and have an handler for that. Using the debugger, it is easy to figure out where there are cross-thread operation provide that you stop on exceptions. That solution should work fine provide that you don't need to much communication with the UI (say less than 100 calls per second). If there is much more communications, then you would need to invest time learning multithreading so that you could write efficient code.
Philippe Mori 8-May-17 12:40pm View
Even if you found a way to do it, you would have to declare the mapping somewhere...
Philippe Mori 20-Apr-17 19:15pm View
You are contradicting yourself. In solution 1, you said in a comment that you are compiling in 64 bit on a 64 bit machine...
If a program does not work, it is because you wrote incorrect code... or you improperly install SQL server (for ex. only the 32 bit version). But those things are documented on the web so you just have to read it and be careful...
Philippe Mori 18-Apr-17 18:55pm View
If you want to do such search, then your design is somewhat suspicious. Using a map where the key would be the second item of your pair and the value the first one would be more sensible. If you really want to search such item, then you can specify a predicate when doing your search. In any case, reading the documentation might be a good idea.
Philippe Mori 18-Apr-17 18:47pm View
Well, as it is obviously managed class, the forward declaration also need the ref modifier.
Philippe Mori 18-Apr-17 18:43pm View
Even though Emglish might not be your first language, you might at least make the effort to format your code.
Philippe Mori 18-Apr-17 18:38pm View
In addition to other comments, make some effort when you ask a question. Properly format code would usually take less than a few seconds.

Obviously, you should not do authentification code until you learn about SQL injection and properly hashing passwords...
Philippe Mori 10-Apr-17 20:09pm View
And it won't hurt to format your code properly. You might even get more help and less down votes. Almost no one would read such unformatted code.
Philippe Mori 8-Apr-17 10:23am View
Usually, it is a bad design when a component need to know its parent. You should use events for that purpose.
Philippe Mori 8-Apr-17 10:10am View
Are you too lazy to show us the error message and tell us which technology you use to build your installer? Obviously, if you have so little information, it is hard to help you and no one would like to waste time explaining all possibilities... Also much information is already available on the web.
Philippe Mori 5-Apr-17 7:33am View
See my other comment... I didn't realize that the list was by value. Replacing the whole list is not what I would usually expect.
Philippe Mori 5-Apr-17 7:31am View
Well, I didn't pay attention it was a value. Usually ehen I have such embedded container, I would use push_back (or push_front if reversed order is desired) similar to CPallini comment below. Usually, it does not make much sense to replace the whole list as you typically want to update existing list.
Philippe Mori 4-Apr-17 18:56pm View
There is a missing new before list constructor...
Philippe Mori 30-Mar-17 22:56pm View
Even if it was possible, you should not do it. It is well known that service should not interact with the desktop so stop doing it. If you need to interact with the user, then create a application that is run under the user account. Stop trying to hack the system or listen to stupid requirement.
Philippe Mori 2-Mar-17 20:32pm View
- Why search has an array of pointers?
- Where are your prototypes?
- Why you don't properly format your code?
- Are you sure it compiles without warnings?
- And using different name for your variables might help you understand your code.
Philippe Mori 25-Feb-17 13:35pm View
Most probable reason is that you must specify which encoding is used for your file.
Philippe Mori 25-Feb-17 13:32pm View
Write real code... Also closing is not the same as hiding. And explain the problem with this code.

Also please use code block for the code.
Philippe Mori 22-Feb-17 7:16am View
If you try something and it does not works, at least don't write random code hoping it will works. At that point, it might be preferable to ignore minor issues like the wrong control has the focus until you have more experience. Given that you want to put the focus inside a control on the web page, you might need to somehow modify the page itself... You have no control on external page like that one. By the time, you get it to works, Google might decide to modify the page. Also, they might have web service for that and you also have to ensure that you follows the rule about permitted usage.
Philippe Mori 18-Feb-17 12:09pm View
Use Google and type string split. You will find a lot of information.
Philippe Mori 18-Feb-17 10:07am View
That answer does not make any sense. You are replacing code is reading text with code that is writing text. And obviously if you use SelectedItem then you must be sure that one item is selected. By the way, the debugger would immediately show you the line where the exception occurs and then it is almost trivial to figure out the problem.
Philippe Mori 18-Feb-17 10:03am View
As a solution, it would worth 5 points...
Philippe Mori 18-Feb-17 9:50am View
Use while loop instead of do while here (and a single variable).
Philippe Mori 18-Feb-17 9:50am View
Use while loop instead of do while here.
Philippe Mori 18-Feb-17 9:50am View
Use while loop instead of do while here.
Philippe Mori 18-Feb-17 9:39am View
That code does not make much sense. Timer are not intended for timing purpose but to raise an event after some time is elapsed. Also timer are not very precise. If the system is busy, events will be late and your computed time would be shorter than expected. It might be a good idea to read documentation before writing code.
Philippe Mori 18-Feb-17 9:32am View
Well, it is preferable to use std::vector instead as it will automatically release memory when the array goes out of scope.
Philippe Mori 14-Feb-17 22:37pm View
This one say to fix the slowness. Other answers mainly suggest to increase timeout.
Philippe Mori 14-Feb-17 20:54pm View
But in my opinion, this is the best answer... If a query take so log that a timeout occurs, then the database should be optimized or the stored procedure should be rewritten in a more efficient way or both or you should consider if you really need that information at once.
Philippe Mori 14-Feb-17 20:49pm View
Also, you should almost never have a catch statement that hide exception. There are very few situations where one really want an empty catch block. By the way. reading books on writing good code might be a good idea.
Philippe Mori 14-Feb-17 20:43pm View
Setting TopMost when you loose focus does not make much sense either. And if you do weird things like that while processing a message somehow related to activation, it might be a reason why your application behave so poorly.
Philippe Mori 14-Feb-17 20:41pm View
That code does not make any sense... Why would you minimize a window to immediately restore it? Why would you call Show() three time in a row. If you application behave improperly, then either you do not properly set ownership or enabling or something like that. You should almost never need to call BringToFront() or Activate except if you have multiple Windows and clicking on a button in one should activate the other windows or something similar or maybe if you hide and show an existing Windows or if you try to simulate modal windows with modeless one and do it improperly.
Philippe Mori 14-Feb-17 20:32pm View
Well, to have some credibility, you need either a diploma or some experience. If doing a degree is not possible, then taking a course or 2 might be a good idea. Well, if you really want to learn by yourself, then start by learning one language (say C#) then learn to develop applications. There are a lot of information on the web. After listening a few videos, do some tutorials...
Philippe Mori 14-Feb-17 20:20pm View
You need to ensure that coordinates in e.Location are relative to the control that contains the bitmap and that the bitmap fully cover the control. So at each step compare actual values with expected ones...
Philippe Mori 6-Feb-17 21:11pm View
Well, the problem is that you are confuse by how C++ interpret "equation". In C++, you have to put on the left the variable that get the result and on the right the equation itself. So you would have TR_ = TF_ + 459.67; for example.
Philippe Mori 3-Feb-17 16:02pm View
A good start is to do "Clean" your solution for each configuration.
Philippe Mori 3-Feb-17 10:17am View
It is well known that Office interop should not be used on a server. It is not designed for that purpose and even if you make it works, it would be very slow. Having said that, if you don't listen common advices, you would still need to buy a licence for that computer. Don't expect that to be possible if you use shared hosting. By the way, there are many alternatives. One is Open XML SDK.
Philippe Mori 3-Feb-17 10:10am View
Not a good idea to modify how controls are expected to works. People will hate your application.
Philippe Mori 3-Feb-17 10:09am View
Don't repeat the same thing twice. If instead of writing the same thing twice, you would provide some extra information, it would be more useful. Don't expect much help if you don't make effort in writing a good question. By the way, where is your source code? And an example won't hurt either.
Philippe Mori 3-Feb-17 10:04am View
F1 should be used for help in your application.
Philippe Mori 2-Feb-17 17:17pm View
Even original code should have been enough... In fact, if OP used ?:, he should know what it does.
Philippe Mori 2-Feb-17 17:14pm View
The idea is correct but not the displayed text. You either want to leave the field blank or display some text that clearly show that the value cannot be computed.
Philippe Mori 2-Feb-17 17:12pm View
And then the user (or the QA) decide to try to test -0.0000000001 and it crash again. In that case, normally you will write a custom string ("", "-", "n/a",...) instead and at some point do validation and show that the value are not valid to the user.
Philippe Mori 2-Feb-17 8:37am View
Even if the code works, you should still write simple and readable code. Your code has way too much noise that only make it less clear.
Philippe Mori 2-Feb-17 8:31am View
You should have written what it is displayed.
Philippe Mori 2-Feb-17 8:29am View
Well, the rules for C# are well defined but it still a bad idea. See my answer.
Philippe Mori 2-Feb-17 8:28am View
Well, the rules for C# are well defined but it still a bad idea. See my answer.
Philippe Mori 2-Feb-17 8:28am View
Well, the rules for C# are well defined but it still a bad idea. See my answer.
Philippe Mori 1-Feb-17 9:33am View
So fix your code by removing the reference: Time operator++(int).
Philippe Mori 1-Feb-17 9:25am View
As far as I know, the fact that a user defined operator is used have no impact on the expression evaluation order. The main problem is that the postfix operator is incorrectly defined and thus does not provided the intended behavior.

I think the only operators for which user defined operator change how the expression is evaluated are && and || as short-circuit evaluation does not works in that case as both side need to be evaluated before calling the operator function.

For any other operators, the main problematic case is when the same variable is used multiple time in an expression in which there are no sequence point... Same kind of problem could occurs with user defined functions.
Philippe Mori 1-Feb-17 9:24am View
Also your comments about the displayed values does not match the actual code. Your code would display H:12M:1. If you take the time to write what the code output, at least make the effort to match the actual output. 
Philippe Mori 1-Feb-17 9:21am View
By the way, in my opinion it is not a good idea to overload ++ operator in this case as it might not be obvious that the increment if 1 minute. What if at some point, you decide that Time should have a resolution of 1 second. It is better to be explicit and it will make your code easier to maintain.
Philippe Mori 1-Feb-17 9:17am View
You should almost always follows predefined operator signatures when you overload an operator. Postfix operator should be declared as Time operator++(int). It is always a good idea to read the documentation before writing code instead of guessing and then wondering why the code does not works.
Philippe Mori 1-Feb-17 8:58am View
But you should also returns the time by value in that case.
Philippe Mori 1-Feb-17 8:50am View
My vote of 1: That code is vulnerable to SQL injection.
Philippe Mori 25-Jan-17 14:08pm View
If you use your original code and both solutions 2 and 3, then it is trivial to solve your problem... If you expect us to give a complete solution, then you won't learn much and not improve yourself.
Philippe Mori 25-Jan-17 12:45pm View
Don't reinvent the wheel... In any case, it does not make sense to do such complex project if you are not even able to start the project without help.
Philippe Mori 25-Jan-17 12:40pm View
Using non standard rounding seems suspicious...
Philippe Mori 25-Jan-17 12:39pm View
But it will not do the same thing for .495!
Philippe Mori 25-Jan-17 12:36pm View
Use a code block to format your code. If you are too lazy to write properly formatted and indented code, then you don't deserve much help.
Philippe Mori 25-Jan-17 12:34pm View
Avoid using macros when not necessary and avoid putting complex code in macros. Use inline functions and constants whenever possible and macro only for the part where there are no alternative.
Philippe Mori 25-Jan-17 12:26pm View
Do you really want to ask both numbers again if one is negative?
Philippe Mori 25-Jan-17 12:24pm View
Should be a function as in solution 2...
Philippe Mori 25-Jan-17 12:23pm View
Validation is missing to ensure positive number...
Philippe Mori 21-Jan-17 13:45pm View
It is not polite to say "urgent" on a public forum. We are not paid to answer you and do not even have any obligation to answer any question. In any case, you will only get poor rating on the voting system by being arrogant and asking poor questions.
Philippe Mori 20-Jan-17 8:24am View
Where is the question? Why don't you format your code? And where is the "list" of exceptions in all that?
Philippe Mori 17-Jan-17 15:23pm View
If you plug the printer to the server (by USB, not network), would not all of this be already handled by Windows (on the server)...
Philippe Mori 17-Jan-17 15:19pm View
However it might make sense to have a server anyhow and communicate with a server instead of directly communicate with a remote database... That way, the client code depends on a web service instead of the actual database and it would typically also be more secure as there are no database access.
Philippe Mori 13-Jan-17 16:04pm View
Write correct code and you would not have segmentation fault. It is as simple as that.
Philippe Mori 13-Jan-17 16:04pm View
Do one thing at a time... Start by a simple program and write one line of code at a time.

By the way the compiler error message clearly explain that it cannot convert an array of integer to a pointer to a pointer to an integer.
Philippe Mori 13-Jan-17 15:44pm View
By the way, how can you have an integer with a value of 8.4? If you don't understand what an int is, there, for sure, you should read books to learn or stop sleeping at school.
Philippe Mori 12-Jan-17 15:23pm View
Why peoples want to bypass any security features Microsoft has added since Vista...
Philippe Mori 12-Jan-17 13:58pm View
You should never do that. You are clearly abusing user system by playing with system time. You have no right to do so. People should not buy your software... as you don't respect them.
Philippe Mori 11-Jan-17 15:24pm View
And what is the output... Do you expect that we will also try the program to make sure we correctly answer you?

Search pointer arithmetic in C and you should understand a lot.

In your example, you can easily see that you call the function with a pointer to number 10 in the array. The loop start with i equals to 4 and multiply that pointer by 4. On next iteration, it will multiply by 3 the value 2 items before thus 4 * 3 = 12. And then it will stop. So it should print 2, 12, 8, 40.
Philippe Mori 5-Jan-17 15:15pm View
Even your data has no time that is 192 minutes apart... For example, if you start at 2:00 then next time should be 5:12. Thus given such inconsistencies, how do you expect us to figure out you problem? Obviously, with functions like DateTime.AddMinutes, it should be trivial to solve you problem as Microsoft has already wrote that code and also the code to compare time thus making it very to figure if a time occurs during lunch and adding an extra 30 minutes... well I guess there are multiple lunch in a day but it is not specified in the question...
Philippe Mori 5-Jan-17 14:59pm View
Go to school and listen to your teacher... or read some books.
Philippe Mori 5-Jan-17 14:57pm View
DateTime and TimeSpan have all necessary functions and operators for basic time computation. If you would read the documentation, it would help you a lot.
Philippe Mori 5-Jan-17 14:45pm View
And the answer is obvious : use a debugger to see where you have made a mistake. Start with 2 or 3 items in different order.
Philippe Mori 5-Jan-17 14:37pm View
Once logged, you know which user is logged in so what's the problem?
Philippe Mori 5-Jan-17 9:28am View
You should learn minimal database development first... If you don't even understand database ID generation, then you should not write code at this point.

People that try to write code without learning basic stuff like you do are creating bugged software because they have no idea of what they should do.
Philippe Mori 5-Jan-17 9:14am View
Seriously, if one is starting a new application in 2017, he should forget about XP.
Philippe Mori 5-Jan-17 9:11am View
If the images are that big, then depending on the image format, you might not even be able to read them from disk at that rate... For example, RAW images from a digital camera are quite slow compared to JPEG files.
Philippe Mori 5-Jan-17 9:01am View
Something like that would works : sum = num > 0 ? (num + 8) % 9 + 1 : 0;
Philippe Mori 3-Jan-17 9:52am View
Format your code... if you want to have some points.
Philippe Mori 3-Jan-17 9:44am View
You would use a database to store information and not create new ASPX files on the server. And when the user ask for a page, you would retrieve the information from the database and generate a page from that using an ASPX page as a template.

And by the way, there are many existing CMS systems so why would you create your own?
Philippe Mori 3-Jan-17 9:36am View
The proposed code here will do exactly the same thing as your code but with less overhead.

By the way, why are you asking a question if you don't want to listen to experts... 
Philippe Mori 3-Jan-17 9:24am View
Where is your code? It is hard to help you if we cannot see what you do. Post relevant code with your question.
Philippe Mori 3-Jan-17 9:21am View
Instead of posting 2 partial answers, you should have post one good answer...
Philippe Mori 1-Jan-17 19:34pm View
For Windows applications, you should probably prefer either WPF or UWP using C#. And even WinForms would still be preferable than MFC/C++. If you use an old technology, your apps might look old fashion...
Philippe Mori 31-Dec-16 13:21pm View
You should never do explicit string manipulation on filenames when there are already functions that does that in System.IO.Path class.

And learning how to use Google or some other search engine would be a good resolution for 2017. With very minimal search competence, one can find that in less than 10 seconds (Bing: c# remove file extention - first result) : Remove file extension from a file name string
Philippe Mori 31-Dec-16 13:14pm View
Doing that kind of stuff is very suspicious...
Philippe Mori 31-Dec-16 13:11pm View
Singleton is a anti pattern. Best way to use it is to not use it.

Bing: singleton anti pattern
Philippe Mori 30-Dec-16 12:24pm View
Instead of trying Func<T, void>, what would happen if you use Action<T> instead? An Action is essentially like a Func without return value.
Philippe Mori 28-Dec-16 16:49pm View
You should refactor your code... For example, the win function has 2 parts that are identical except they check for X or O. You can make a function that would take a parameter for the character (X or O) and returns true or false. Also code for testing each row is similar so you can have a function to test specified row. You can do the same for columns... Afterwards, you might do similar refactoring for the AI and then use loops. Once you have improved code, it would be easier to fix it.
Philippe Mori 24-Dec-16 10:14am View
Make some efforts when answering answers. Is it that hard to:
- Properly start sentence with an upper case letter.
- Add missing punctuation like : when appropriate.
- Properly use code block everywhere.
- Avoid abbreviation like "Plz".
- Don't repeat the same thing twice (Add using System.Linq;).

Given your low effort, you will probably get a low vote rating!
Philippe Mori 24-Dec-16 10:06am View
Floating point values are not exact. So your have to properly round them when converting to avoid something like 58.9999 to be truncated to 58. As far as I known, the FPU will round numbers but C/C++ will truncate them.
Philippe Mori 23-Dec-16 10:01am View
There are mainly 2 possibilities:
1) Use WPF instead of Windows Forms.
2) Buy some third-party component that has that control.
Philippe Mori 23-Dec-16 9:59am View
2 solutions:
1) Develop your application in WPF instead of Windows Forms.
2) Find software component that does what your want and buy it.
Philippe Mori 20-Dec-16 21:00pm View
If you have a hash table, it was probably done for performance purpose of supporting a lot of users with minimal overhead. So it probably does not make much sense to use a list instead. You probably cannot simply add user at the end since you probably have to ensure that the user is not already in the table. And you don't need a list to iterate over existing values. Also, where is your code?
Philippe Mori 19-Dec-16 19:08pm View
If you got that error, then you are probably using int.Parse and the input is not valid. Please post the real code you are using. Also, if you get an error, you should also indicate the content of the text boxes.

Another thing is that you should give your controls meaningful names. textBox00 is not very informative.

And given the fact that a text box could be empty or contain something that is not a number, you usually want to do the validation in multiple steps so that you can display the most appropriate error to the user.
Philippe Mori 18-Dec-16 17:42pm View
You cannot have multiple colors in standard WinForms TextBox. It is not clear from your question if the text box is only used to display information (read only) or the user could also type in it. If the user does not need to type information, you can use an embedded web browser for example.
Philippe Mori 18-Dec-16 17:36pm View
That code does not make any sense :

1) You never want to call Sleep form the UI thread.
2) You almost never have to explicitly call Update() explicitly.
3) Why would you update the text 3 times when it could be done once.
4) Hard-coded strings is generally not a good idea.
5) And your text box is poorly named.

And also, it is very stupid to write twice the same question. The What I tried section is not to repeat the same thing that was written in the question. People that waste other time by making then read the same text twice do not deserve much help.
Philippe Mori 17-Dec-16 22:56pm View
This make absolutely no sense at all. You never, never write code like that. It has security issues and it is not maintainable at all. And how the code would update itself when a user change his password or register himself. It would be a good idea to read tutorials on that. It should be easy to find information on the web.
Philippe Mori 16-Dec-16 9:37am View
Write code, write code and write more code...
Philippe Mori 15-Dec-16 10:04am View
WinForms or WPF. I have assumed WinForms in my answer as you could do almost anything you want in WPF and it would not make much sense to ask a WPF question without specifying it.
Philippe Mori 15-Dec-16 9:51am View
As suggested, it might make sense to create a combined project. When you debug a client/server, usually you have some time out (on the client) if it take more than a few minutes to debug the code on the server.

For testing purpose, you might use hard-coded values so you don't need the whole client code.

In reality, in a properly designed application that kind of code would be testable and you would instead debug your unit test to see where the function fails.
Philippe Mori 15-Dec-16 9:44am View
You might try to split the request in 2 or 3 parts and see if it is better to have a few optimized requests that a single one not optimal...

By the way, I assume that you already check that the generated request was not degenerating in a bunch of request (for your specific provider).
Philippe Mori 13-Dec-16 16:37pm View
As the values 0, 1 and 2 probably do not represent real values, you should uses Enum instead.
Philippe Mori 13-Dec-16 16:36pm View
You should put sample code in your question in a code block to make it more readable. Having said that, I would say that the solution really depends on what you do within each case... Given that there are 243 possibilities, it is very suspicious that you would write a check and a code block for each one.
Philippe Mori 13-Dec-16 16:29pm View
If the conditions are mostly exclusive, that might make some senses but I would use Action<> or Func<> as the array type and put code there.
Philippe Mori 13-Dec-16 16:23pm View
We don't know how to answer you... Not enough code or information for us to know what you are doing wrong.
Philippe Mori 13-Dec-16 16:01pm View
It might the garbage collector that kicks in... but I think it would essentially only affect the application itself.
Philippe Mori 12-Dec-16 16:43pm View
Learn to write code that make sense. For example, your sum function should look like:

int sum(int a, int b)
    return a + b;

All the other extra stuff is either useless or bad.
Philippe Mori 12-Dec-16 16:34pm View
Are you too lazy to format your code?
Philippe Mori 12-Dec-16 16:33pm View
What is the relation between Shift + C and your code?
Philippe Mori 12-Dec-16 16:30pm View
This is a bad UI design. You should always see all related radio buttons at once.

And there is nothing difficult to uncheck a radio button as you just have to set its Checked property to false.
Philippe Mori 12-Dec-16 10:57am View
Well, it might eventually be possible using the API and "low level hacks" but it won't worth the complexity anyway. If you are not able to figure out by yourself how to do that kind of stuff, then you will probably not be able to handle all the bugs that occurs when you try to do something the system was not designed for (and not tested for).
Philippe Mori 10-Dec-16 11:10am View
Read about DRY: Don't repeat yourself
Philippe Mori 10-Dec-16 11:04am View
Well, hard-code 100 here is really bad. If you convert an array to another one, then you should use the length of the first array for the size of the second one.
Philippe Mori 10-Dec-16 10:58am View
As suggested in solution 1, I recommend you to use a dialog based upon the OpenFile dialog. And I suggest that you make your own wrapper so that you can select at one location if you want to use SHBrowseForFolder, IFileDialog or customized OpenFileDialog (WinForms).
Philippe Mori 7-Dec-16 11:19am View
Use a debugger to figure out how your program works instead of guessing. By tracing the code line by line, it should be trivial to understand what every line do.
Philippe Mori 7-Dec-16 11:17am View
It is not very clear how those 3 classes relate to each other. The above code modify the variable card13 so that it is a distinct object than the one inside packCards_1 but with the same values (at the time they were copied).

I would recommend you to learn more deeply the C# langage and good design/coding practice before writing a lot of code...
Philippe Mori 7-Dec-16 11:12am View
Well, it might be a good thing to try for OP so that he can figure if this is really what he want to do...

However, if one want to be able to copy many or all properties from an object, there a function for that purpose should normally be created.
Philippe Mori 7-Dec-16 11:06am View
Something is missing in that question as at first glance there are no visible problem. So the problem might be related to how some other symbol is defined.

Maybe there are some macro tricks or some platform/hardware specific stuff...
Philippe Mori 7-Dec-16 10:58am View
If you write suspicious programs, then your are not a developer but a hacker so the rule to not make you feel stupid does not apply!

There are almost no good reason to do that. Either you are running on a regular PC and should not do that kind of thing or Windows is run in a mode that should not let the user have access to the system anyway (think applications that run in public places).
Philippe Mori 7-Dec-16 10:40am View
Since Windows 8, the start menu has changed a lot... and adjustment were made a few times. If what you are trying is not working, there I would think it is not supported anymore as the main philosophy behind the new system is that the user should customize its menus and application should generally only add the main shortcut.
Philippe Mori 7-Dec-16 10:32am View
Write real code in your example.
Philippe Mori 7-Dec-16 10:25am View
If you have tried, then how come there is no code in What I have tried: section.
Philippe Mori 7-Dec-16 10:22am View
The best practice is to test by yourself. That way, you will have a better understanding of the impact in your specific application. By the way, it is always a good idea to ensure that database is properly indexed and that relatively optimal queries are made. I often use LinqPad to test my query. You have to ensure that you user the same driver to access that data than the one used in the application.
Philippe Mori 7-Dec-16 10:09am View
Nice suggestion to use a switch statement. However, this answer does not bring enough value to the existing 3 answers. A comment to the question or another answer would have been enough.
Philippe Mori 7-Dec-16 10:05am View
As there was already a call to char.ToUpper just after reading the value, it does not make much sense to now convert it to lowercase. Instead, he should either compare with 'X' or change the original function cal.
Philippe Mori 7-Dec-16 9:58am View
You don't show the definition of Card class. By the way, naming controls with numbers rarely make sense. And where is the question?
Philippe Mori 6-Dec-16 9:26am View
Well, then your problem is that you don't seems to realize that when you write "\xE4", it means a string with character code E4 and not the string @"\xE4". Thus you ask an incorrect question. OriginalGriff exactly respond what you have asked but it was not what you wanted. If appending "\xE4\xD5" works, then you need to send the bytes values. Thus even ToHexString function is incorrectly named. You would have to do something like sb.Append((char)t);
Philippe Mori 6-Dec-16 9:16am View
By the way, string in C# are in UTF-16. So there might be some conversion from that encoding to the one used to send data to the printer. We have to know if you are able to properly print using any of the above.

It might also be useful to show how you would print "ABC" and to test if that works.

The information in the link you provide (ESC-POS Arabic letters is separated) are somewhat different that the one here. It would be better to provide all necessary informations.

By the way that question does not make much sense. What does it means that letters are separated? Would you expect E4D5 without a space? It cannot be since this is an hex dump of bytes and bytes are 2 characters wide when printed in HEX.
Philippe Mori 6-Dec-16 9:02am View
I add a comment asking for which hard-coded value would works... If OP can answer that, then we would be able to confirm if he want what he has asked.
Philippe Mori 6-Dec-16 9:01am View
There is an inconsistency in your code and your question... As presented, it seems that you want to escape only the content of str1 but not commands like Initialize Printer.

If you would hardcode str1, would you write receipt.Append("\xE4\xD5") or receipt.Append("\\xE4\\xD5") or receipt.Append(@"\xE4\xD5") or receipt.Append("E4D5")?

Would that hard-coded string works? Which ones?
Philippe Mori 6-Dec-16 8:46am View
For improved readability, you can write @"\x{0:X2}" instead. It will output the same string.
Philippe Mori 5-Dec-16 13:57pm View
Well, a somewhat good guess when one have no idea might be 5 times your estimate...
Philippe Mori 2-Dec-16 11:49am View
One possibility is to design the UI at a fixed size and the zoom the content to fit the available space using a ViewBox.

You might also check the related questions on the sidebar.
Philippe Mori 2-Dec-16 11:41am View
Also never write the question twice. It is very frustrating to read the same text twice because someone is too lazy to fill What I have tried and simply copy and paste the question he already asked.
Philippe Mori 2-Dec-16 11:21am View
Never modify a question in a way that make old response appears off topic. If new question is directly related to the original question, you might append new information and clearly indicate the added section to the question. In any other case, ask a completly new question.

What you are doing is a very bad idea as someone who would have a similar question and use Google might find a question where the answer does not seems to be related to the question.

Even worst, by doing that, you might cause other people answer to be downvoted. Thus it is a complete lack of respect of other people.

This is abusive.
Philippe Mori 2-Dec-16 11:11am View
A site like this one is not indented for people doing other people homework but to give specific answer to specific coding problem.

Obviously, we cannot help someone without code nor question.

Also, if you loose your work, then you have to start it over. It was up to you to make backup or use source control. At least, since it was done once, it you restart it right now, you might remember a lot of what was done so you should be able to do it in less time than the first time.
Philippe Mori 2-Dec-16 11:00am View
If some content can be scrolled, then you should always show the scrollbar anyway so it would be a bad idea to help you doing bad UI... In any case, it is relatively easy to control the visibility of scrollbar for more controls.
Philippe Mori 2-Dec-16 10:58am View
You probably don't want backup/restore code to be in your ASP.NET MVC code. How would you do a restore when the site is not working because the database is corrupted. Obviously, you don't want to show such command to all users and thus the site would depends on the logged user which will typically depends on a working database.
Philippe Mori 2-Dec-16 10:15am View
For completeness, it might be good that you would provide links that were useful for you and a bit more explanation (or code) on how this is used.
Philippe Mori 2-Dec-16 10:13am View
Well, it is still better to provide an answer from other comments that to have no answer at all. I am not very experimented with WPF. The only thing, I have done is guessing a relatively good starting point search query.
Philippe Mori 1-Dec-16 23:02pm View
Well, I would not say that the professor is idiot... It should be obvious that if one want both array to be updated, he just need to add a few lines to move also name (in the other array) when sorting. It would be idiot if the alternative of using objects is not shown at some point in the course.
Philippe Mori 1-Dec-16 22:55pm View
Well, the following search might give you some hints : bing: wpf decorator control. I don't know enough about WPF to help you more.
Philippe Mori 30-Nov-16 11:38am View
Not enough information is provided. You have to show the namespace and using declaration. Ensure that the appropriate assembly is referenced and that you have the appropriate using at the top of the file. It would also be a good idea to avoid using the same name and case for a type and a variable as it can cause additional problems if you don't do it the proper way.
Philippe Mori 29-Nov-16 10:33am View
Although the documentation is helpful, I think that adding specific information to the answer would be useful.
Philippe Mori 29-Nov-16 10:24am View
One example where your code would probably fails is CString a = CString() + CString(" World");. That is if you replace the first constructor call so that the default constructor is used.

Also operator= should return a reference.
Philippe Mori 29-Nov-16 10:17am View
Although writing a string class is a good exercise, one should usually use standard string class in production code as the standard class was coded by experts who have a better understanding of pitfalls like those.
Philippe Mori 29-Nov-16 10:14am View
Generally, it is better to implement operator= using the copy constructor and swap idiom as it make it easier to write exception safe code.

Also, in your case, the copy constructor might fails while calling the assignment operator since cstr has not yet been initialized.
Philippe Mori 29-Nov-16 10:10am View
Even worst would be data on the stack or that are otherwise deleted while the string still reference that copy...
Philippe Mori 28-Nov-16 9:52am View
How long do it take to process one item? When pausing, can the current item be terminated? How many item do you have?

These details are important to suggest best solution as otherwise we only can make a guess but it might no be the best solution.

By the way, you probably don't want to keep the connection open while in pause state.
Philippe Mori 28-Nov-16 9:42am View
What is the column definition of codemeli in the database? And as suggested by someone, use parametrised query parameter for that parameter too.
Philippe Mori 28-Nov-16 9:33am View
I think that it is not possible without installing a driver for that purpose... so the easiest solution is to turn off the microphone input while recording.
Philippe Mori 25-Nov-16 17:01pm View
Given than OP said that he is learning by his own, I don't think we help him by giving him exactly what he asks... but instead we should suggest him the best way to do it which is already what he has done.
Philippe Mori 25-Nov-16 16:59pm View
Is it an assignment or something you want to do by yourself. If it is an assignment, then checkString from solution 2 would be what you ask.

And if it is your own code, then in that case, it does not make sense to replace int.TryParse by something else as it already does exactly what you need.
Philippe Mori 25-Nov-16 16:56pm View
Well, then OP idea is wrong if he wants to do that by himself... and if it is an assignment, then Solution 2 checkString function is much better than yours.

So maybe I misread OP question but obviously from its code, it would make no sense at all to write such function...
Philippe Mori 25-Nov-16 16:25pm View
Calling int.TryParse is preferable over your IsThisAnInteger function as it will do the validation, the value is ready for use, the code is shorter, it require to pass a string and it use framework code.
Philippe Mori 25-Nov-16 10:43am View
It might be a comment but it is surely not an answer.
Philippe Mori 25-Nov-16 10:41am View
The What I have tried: section is not intended to write dots. So if you want help, improve your question.

And do you really expect help with such little information? We don't even know which UI technology you are using.
Philippe Mori 25-Nov-16 10:36am View
Use a code block to format your code. No one like to read unformatted color without syntax coloring. By taking an extra minute when asking your question, you would improve by a huge factor the chance that someone help you. I rarely help people that do at least some effort.
Philippe Mori 25-Nov-16 10:33am View
Edit your question to properly format it...
Philippe Mori 25-Nov-16 10:28am View
Why writing the same code twice? Why not properly indent it? And why not explaining the problem?
Philippe Mori 25-Nov-16 10:24am View
Never kill a thread. Learn multithreading by reading books or doing tutorials. You don't want to improvise code without understanding how it works...
Philippe Mori 25-Nov-16 10:20am View
By the way, what OP does is already better that what you propose to do...
Philippe Mori 25-Nov-16 10:18am View
In Visual Studio, you can select some code and right-click and there will be an option to generate a function.

Otherwise, you are better to read some books or tutorial and try thing as you learn them...
Philippe Mori 24-Nov-16 11:09am View
As I said, if one information is missing, you won't find the record because you filter on all fields.

Although if the user enter a single information, it would be trivial to use || instead of && so that it could match any of the field, it won't works well if the user want to enter multiple informations but not all.

You might be able to count the number of matches but then the query would probably become too complex and it might fails or be very slow.

Thus, as I said, the best option is to have one field in your UI for each column in your database. That way, you can easily filter appropriate columns.

Well, if the data is really small (say less than 100 entries maximum), you might be able to do the filtering in memory (and not be limited by the complexity of a SQL query).
Philippe Mori 24-Nov-16 10:40am View
It really depends on how much effort you want to put in validation... and which kind of validation you want to do and how precise you want your error messages to be and the kind of error reporting you want.

The first trick is to reduce the possibility of errors by using appropriate controls (for example, a numeric up-down to enter a number or a calendar popup to enter a date).
Philippe Mori 24-Nov-16 10:23am View
Start by putting your file in All users documents...
Philippe Mori 24-Nov-16 10:20am View
Just require that the user enter at least one digit or special character and you would never have any word that is in the dictionary.
Philippe Mori 24-Nov-16 10:16am View
If you want to search specific things, then it would be better to display 5 fields on the web page and filter data as appropriate depending on which field was filled.

You have not clearly explained the problem with your code... It might not be obvious for everyone on the first reading that your code would fails to find an item as soon as one information (caste, country, city...) is missing from the words.
Philippe Mori 24-Nov-16 0:06am View
Is it that hard to use a code block to format your code.
Philippe Mori 24-Nov-16 0:05am View
Then if you have found the solution by adding/substracting 0.5, then what is the question/problem. Once, you know the rule, you write code so that it works as expected.
Philippe Mori 24-Nov-16 0:03am View
If you use ceil, then you would have the opposite problem where the result is higher than expected for some number. Thus rounding should be used.
Philippe Mori 23-Nov-16 9:43am View
You don't really explain what to do or where to start....
Philippe Mori 22-Nov-16 15:41pm View
But it is probably not the answer is teacher is expecting... Usually, students are expected to mainly used what they should have learn at that point.
Philippe Mori 20-Nov-16 23:46pm View
2016 - 100 would give 1916 which would overflow a byte. It serve no useful purpose to fix the conversion to BCD if the input is wrong. The problem would be even worst in BCD as BCD could only represent 100 numbers... In that case, it won't give a valid BCD number.
Philippe Mori 19-Nov-16 14:54pm View
Use a code block to format your code.
Philippe Mori 18-Nov-16 11:22am View
Well, it is far better... However, it is not clear exactly what you want to do and what is the problem you have. It is easy to understand that the code above would show a message box for each text box that is empty...

But in your question, it seems that you want to display a message if not all textboxes are empty (that is some of them do contain some text).

Well, usually one should stop looping after the first error as otherwise it would be very annoying to respond to many message box before fixing the first problem. Also, it is a good idea to put focus on the (first) control that is not valid.

Thus in your code, I would add c.Focus(); break; after displaying the message to the user.
Philippe Mori 18-Nov-16 10:22am View
now.Year - 100 is suspicious. Year in date time are "four digits". So we are in 2016 and not in 16 or 116...
Philippe Mori 18-Nov-16 10:19am View
You should probably also set the thread priority lower than normal so that the service won't have too much impact on UI...
Philippe Mori 18-Nov-16 10:14am View
Try to improve your question formatting and fix spelling errors.
Philippe Mori 17-Nov-16 16:48pm View
Don't mix C and C++ memory allocation. If you code in C++, then use new and if you code in C, then don't use any C++...

In particular, it is undefined behavior if you call delete or allocation made with malloc.
Philippe Mori 16-Nov-16 9:37am View
Excel 2003... which is not supported anymore. OP problem is that "bad" file support do vary between Excel version. Generally, we can probably assume that never versions are a bit more tolerant for some kind of errors.
Philippe Mori 16-Nov-16 9:32am View
Even worst, you wrote almost the same thing twice in this question.

And even worst, is that you absolutly don't provide any useful information that would allows us to help you.

Obviously, if you properly create your file it should open in any version of Excel... so if it does not open, something is wrong with your code.

You might consider using some package that wrap OpenXML and make it easier to use. There are many options that can easily be found by managing NuGet packages in Visual Studio.
Philippe Mori 16-Nov-16 9:24am View
This is almost the same question as Why the excel file is not open in office 2007 generated by using openxml SDK? Working in office 2010

Don't ask same question twice. It would be better to write one clear question than 2 unclear ones...
Philippe Mori 16-Nov-16 9:23am View
This is almost the same question as How do I generate excel file using openxml-SDK v2.0 supporting to msoffice 2007.

Don't ask same question twice. It would be better to write one clear question than 2 unclear ones...
Philippe Mori 16-Nov-16 9:18am View
And you have to consider that in some language, a comma is used as the decimal separator...
Philippe Mori 15-Nov-16 19:02pm View
You might try to save the document in 2010 and then open it in 2007 to see if it would open after letting Excel "fixes" the file. If so, then, you can compare both files and try to find where it differs and make some testing to figure out what you need to update.
Philippe Mori 14-Nov-16 15:21pm View
Your question is not clear. Show us what you expect and what you get.
Philippe Mori 14-Nov-16 15:16pm View
It would not be very hard to add an example of expected conversion and to tell on which line the error occurs.