Click here to Skip to main content
15,394,005 members

Comments by Tony Hill (Top 56 by date)

Tony Hill 23-Jun-22 4:31am View
You did not mention that in the original question.
Tony Hill 23-Jun-22 3:43am View
Don't post extra information/comments as a solution.
Tony Hill 23-Jun-22 3:43am View
Don't post extra information/comments as a solution.
Tony Hill 18-Jun-22 12:21pm View
Don't add additional remarks about your problem as a solution add them as comment to who you are responding to.
Tony Hill 16-Jun-22 15:41pm View
I think the OP was more interested in why he could not understand why
using the Add method was not changing the date rather than knowing
how to initialize a time from a string.
Tony Hill 8-Jun-22 15:31pm View
I tidied up a bit to remove the 'PlayAgain' variable and use a break statement to make it a bit cleaner.
Tony Hill 6-Jun-22 14:15pm View
Str2 is NOT in Str1.

In str2 you have a pair of parentheses and "+/g", they do not exist in str1.
Tony Hill 4-Jun-22 15:10pm View
The OP stated that they were not allowed to use any string methods except length but your solution uses the string split method.
Tony Hill 28-May-22 10:32am View
This is a verbatim repost of the OP's question and is not a solution.
Tony Hill 22-May-22 15:29pm View
Just out of curiosity how do you suggest you solve the original problem if you cannot use floats.

For example can the person attending a class attend 3.5 classes or even more puzzling can you hold 2.5 classes.
Tony Hill 24-Apr-22 14:51pm View
As you have not told us what the error is or where it occurs it is very unlikely anyone can help.
Tony Hill 1-Apr-22 7:46am View
The easiest way is to perform the processing on the UI thread by removing the 'async' from the button event signature and the 'await QueuedTask.Run' and let the UI thread load the combobox.

Another way is to use Invoke to get the UI thread to perform the combobox loading.
Tony Hill 1-Apr-22 6:16am View
I tried to access it using Chrome, Firefox and Edge and none of them seem to work.

However I also tried the same three browsers on another machine and I was able to load the page.

Obviously a machine config issue, the only difference between the two machines was one is my work machine with a VPN connected and the other a personal machine with no VPN just a straight connection through a BT router.

I disconnected the VPN on the work machine and tried again and was then able to access the web page.

I am guessing the way the network bods have configured the VPN is at the bottom of the problem in this instance but I don't know if that bit of info is of any use to the OP.
Tony Hill 1-Apr-22 4:04am View
My mistake, just a bit early for me.
Tony Hill 13-Mar-22 13:23pm View
Tony Hill 13-Mar-22 9:00am View
Tony Hill 10-Mar-22 12:46pm View
You should not post a question as a solution to different previously asked question.
Tony Hill 20-Feb-22 14:22pm View
Don't talk nonsense, a 'RichTextBox' does have a Text property.
Tony Hill 12-Feb-22 5:46am View
The OP was not trying to load a cursor from a file but from an embedded resource.
Tony Hill 8-Feb-22 6:34am View
Don't submit a comment or thanks as a solution, submit it as comment.
Tony Hill 6-Feb-22 15:20pm View
I tried your code and it works OK and seems to do what is expected.

I did not get any [Error] no matching for call to 'Employee(const char[12], const char[16], int, int, int)'
Tony Hill 6-Feb-22 14:28pm View
It would help if you could show the definition of the Employee class.
Tony Hill 4-Feb-22 3:04am View
Tony Hill 3-Feb-22 6:27am View
This is just the OP's question code posted as a solution.
Tony Hill 28-Jan-22 9:43am View
Are you using a custom Rectangle class?

Because the standard java class does not have an overloaded constructor that takes doubles as parameters, neither does it have methods called getArea() or getPerimeter.

If you are using a custom class it might be helpful to add that class definition to your question to help us solve your problem.
Tony Hill 27-Jan-22 14:29pm View
I copied your code into a test program and it ran OK, however as I only have certificate on my machine it would not enter the code branch where the SelectFromCollection method is called.

I set a break point on the line

if (store.Certificates.Count == 1)

and when the break point was hit

I dragged the point of execution to the line containing the SelectFromCollection method and resumed execution and a message was displayed about a certificate.

I altered the SelectFromCollection to use the X509SelectionFlag.SingleSelection instead of the X509SelectionFlag.MultiSelection and ran it again and this time a list dialog popped up with just my certificate in the list.

However I noticed that you are using SelectFromCollection method overload that requires you provide a handle to the parent window for the dialog list box, I tried both and did not have anyt issues..

As you are passing the ptr variable set to IntPtr.Zero in the overloaded method and that parent window it occurred to me that the dialog maybe popping up behind visual studio and you can't see it and as you can't see it the next time you run your code it would probably fail as you might not have seen it to dismiss it.
Tony Hill 27-Jan-22 11:32am View
The first thing you should do is fix your try/finally block and put a catch handler in there so when an error occurs it is caught so that it is possible to view the exception data.

At the moment when an error occurs any where in the try block the final block is executed and the program ends without notifying you.

When you used the debugger did the store open successfully?

If the store opened successfully how many records did the store.Certificate.Count return?

The answer to these questions can only be found by stepping the code in the debugger.

Once you have answered these questions it might be possible to solve the problem.
Tony Hill 27-Jan-22 10:37am View
Have you stepped through the code using the debugger?.

Because I can see that just looking at the code at least one problem could occur, so unless you have more than one certificate in the store then the X509Certificate2UI.SelectFromCollection' code will not be executed and therefore you won't be asked.

There are other things in the code which might cause problems but the one I mentioned above is the one that sounds the most likely.
Tony Hill 23-Jan-22 7:01am View
This is not a solution it is a completely different question.

If you have a question then raise a new question rather than posting your question as an in this case irrelevant piece of code as solution to the original question.
Tony Hill 7-Nov-21 14:13pm View
Why did you remove the question you asked, don't you think that leaving the question there might help somebody else and adds context to the solution.
Tony Hill 7-Nov-21 14:12pm View
Why did you remove the question you asked, don't you think that leaving the question there might help somebody else and adds context to the solution.
Tony Hill 18-Oct-21 14:28pm View
If you are going to plagerise solution 2 at least try and get the formatting right.
Tony Hill 10-Oct-21 5:46am View
That is vulnerable to SQL injection, the only way to be safe is to use parameterized queries.
Tony Hill 13-Aug-21 4:24am View
Tony Hill 13-Aug-21 4:23am View
Tony Hill 12-Aug-21 15:53pm View
Having tried your code it falls over with System.FormatException which I presume is what you meant when you said it does not work.

Your problem is you are trying to parse a date 21/04/1990 but you specify that the pattern it must match is "yyyy-MM-dd", to try and parse the date you need to use "dd/MM/yyyy".

DateTime objects do not have a format, a format is used to convert the datetime into a human readable form.
Tony Hill 3-Aug-21 3:43am View
No you are not, when you instantiate the Cell_Phone object in the Main method you only pass the enum to the constructor into the constructor of the Cell_Phone object.

Cell_Phone phone = new Cell_Phone(Brands.Xiaomi);

The signature for the Cell_phone constructor expects three parameters

public Cell_Phone(int productID, double price, Brands brand)

So your options are to pass more parameters when the Cell_Phone object is created or as I suggested alter Cell_Phone constructor to accept just the enum, as I mentioned before the variable ProductID and Price are set in the constructor dependent on the value of the enum used when the Cell_Phone object is created so why do you need to pass them into the constructor.

Becaus the const
Tony Hill 16-Jun-21 15:14pm View
If you want help with this it would be helpful to post your code here so we can examine it to find your problem.

Remember we cannot see your screen or read your mind, help us to help you by showing the code.
Tony Hill 4-Jun-21 12:51pm View
Form2 has two public events called 'form2Opened' and 'form2Closed', other forms can ask
to be notified when these events are raised.

I will only discuss the 'form2Opened' to not complicate matters.

In the Form1 Load event handler method Form1 registers an interest in being notified when
either of these events are raised and the method which should be called when the event is raised.

In the Form1 'Form1_Load' method we create Form2 and register an interest in the 'form2Opened' event and display the Form2.

private void Form1_Load(object sender, EventArgs e)
form2 = new Form2();
form2.form2Opened += Form2HasOpened; // (1)

After the call to ShowDialog() in the Form1 'Form1_Load' method the 'Form2_Load' method
executes, the first thing that happens is Form2 checks to see if anything is listening
to the Form2 form2Opened event by testing to see if it is null or not, if it is not null
the form2Opened event is invoked to notify Form1 that Form2 has loaded.

private void Form2_Load(object sender, EventArgs e)
if (form2Opened != null)
form2Opened.Invoke(this, new EventArgs()); // This will notify Form1 that Form2 has opened and that Form1
// should execute the Form1.Form2HasOpened method.

Control will now be passed to the Form1.Form2HasOpened method (see (1) above) and the code in the
method is executed which in the example will tell Form1 to hide itself with Hide() method,

private void Form2HasOpened(object sender, EventArgs e)

After the Form1.Form2HasOpened method has finished executing control is returned
to Form2.Form2_Load method where the event was invoked.

Much the same sort of thing happens with 'form2Closed' event but you should be able
work it out yourself.
Tony Hill 23-May-21 15:04pm View
Richard, Did you see the sneaky spam link under the Korean text.
Tony Hill 23-May-21 14:40pm View
Can you see the sneaky spam link under the Korean text.
Tony Hill 23-May-21 6:17am View
As Richard said this question was answered nine years and your solution is vulnerable to SQL injection attacks.
Tony Hill 14-Apr-21 7:35am View
It should be placed on its own line after the last line of your code.
Tony Hill 11-Apr-21 5:33am View
I have modified the code in my example, next time you ask a question try and make the intent more clear so others can understand your problem.
Tony Hill 30-Mar-21 11:55am View
Only 7 years late with an answer which does not answer the OP's question, the OP actually wants to focus (highlight) a newly created node in the treeview not focus a control.
Tony Hill 28-Mar-21 7:52am View
Well spotted Patrice T, I knew the maths was wrong but did not spot the lack of a return.
Tony Hill 14-Feb-21 14:27pm View
Do you really think it a good idea to show how to create sql injection vulnerabilities in sql statements
Tony Hill 26-Jan-21 6:36am View
Seems you have done it again
Tony Hill 29-Dec-20 5:44am View
This is just a copy of the first sentence of solution 1.
Tony Hill 10-Dec-20 9:54am View
Tony Hill 18-Nov-20 14:59pm View
Completely unrelated nonsense to the original posters question.
Tony Hill 18-Jul-20 12:37pm View
Unlikely that the original poster is still interested as the question is 5 years old.
Tony Hill 14-May-20 6:05am View
This problem was solved by the original poster 9 years.
Tony Hill 11-May-20 14:44pm View
Apart from answering a 10 year old question you did not answer the OP's question about how to do it in SQL not c#
Tony Hill 8-Mar-20 16:07pm View
Yes but your CupMethod calls the BrewMethod with one argument as doesCupMethod, WaterMethod, SizeMethod, LidMethod.

You have to fix it in all those methods as well.
Tony Hill 2-Apr-18 10:57am View
This is Android Java not C++.