Forgot your password?
Sign in with
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View C++ questions
View Java questions
All Message Boards...
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Design and Architecture
Internet of Things
C / C++ / MFC
ATL / WTL / STL
Objective-C and Swift
Hardware & Devices
Hosting and Servers
.NET (Core and Framework)
Site Bugs / Suggestions
Spam and Abuse Watch
The Insider Newsletter
The Daily Build Newsletter
Most Valuable Professionals
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
What is 'CodeProject'?
Ask a Question
Bugs and Suggestions
Article Help Forum
Comments by jsc42 (Top 39 by date)
That algorithm (plus most others) needs a seed to generate the value. The seed should be randomly chosen, which takes us back to square 1 again unless you have some other pseudo-random number generator to start with (e.g. current time as milliseconds since the epoch mod some large no). Alternatively, see https://xkcd.com/221/ but I doubt that that would be acceptable in the OP's situation.
The settings would have to be User, not Application. But it is the wrong place to save it. You want something that is pan-user, in case a different user uses your application. I assume that the registration details are being saved to a database, so the best place is the save the value in a table in the database.
Also, I note that you are setting StudentNumber as an increment of studentTotal, which you are setting to zero at the start of each run. This is another reason you are restarting the count each time.
Finally, for now, if you have 50 children who attend 200 days a year your counter will roll over from 9999 back to 0000. It would be better if the id number was independent of the year so it can grow as big as it needs.
IE is not completely dead! Somewhat moribund - more like a walking zombie. You can still use CreateObject("InternetExplorer.Application") in a Windows Script File or a Hypertext Application and it starts an IE window. The standard DLL XHTML? is effectively IE7 (so HTML4 + CSS1.0 + JS1.2) but it still works even on Windows 11. ActiveX, therefore, limps along even today.
However, I concur that it has the potential to be a massive security problem and should be avoided like the plague. I only use it for a couple of very old utilities that I wrote for myself years ago, so I know what the safety risks are with them. I would never pick something off the shelf that used ActiveX and have no intention of writing anything using it in the future.
Which browser? Which OS? (ActiveXObject is only supported on MS-Windows)
I use it on *.hta in a script that I wrote for W98 and it still works on W11, but it is generally not regarded as the correct way to do things.
@Chris_Copeland's suggest is good!
If, for some reason (and I cannot think of any time that that is true), you cannot get a name that makes sense; or (as sometimes happens) you need to correct someone else's logic because they got the test the wrong way round, put the false test in parentheses e.g.
if (!(somethingFalse)) // Parentheses highlights the fact that something awkward is going on
alternatively, it is (just about) acceptable to do
// Nothing to do if condition is true
else // Condition is false
I have often seen
If you come across that, invert the code to
Do not skimp on comments. If your code, after careful refactoring, is still not readable, alert the next reader that there is a pitfall to aviod e.g.
// Looking for a missing value
if (!(HasValue(thingBeingTested))) // See if thingBeingTested has not got a value
doNoValueAction(); // thingBeingTested has not got a value
I'm not a Python expert but ...
Doesn't d.remove(a) remove the item in position 'a', not the item with value 'a'?
So, if you have [4, 3, 1, 3, 4]
First Iteration: a = 4 (max n); d.index(a) == 0 and d.index(a) also == len(d) - 1; so you do d.remove(a) meaning remove item 4 which (using zero based subscripts) just coincidentally is one of the items that has a value of 4.
Second Iteration: a = 4 (because there were 2 '4's in the original list); d.index(a) == 0 but not == len(d) - 1; d.remove(a) once again tried to remove item 4, but your list now only has indicies 0 to 3 so the remove will fail.
If I understand the task, then I think the simplest way to implement want you need is to split the tests for d.index(a) into two 'if' branches and when one is true, remove it using the found index (which will be 0 or len(d) - 1)
This is definitely true for HyperText Markup Applications and used to be true for embedded web in forms, but I do not know if it is still true for Windows forms ...
What do you mean by 'partial word'? Do you, for example, mean that if a user enter a search word of 'leapfrog', you would match 'leap' or 'frog'; or do you mean that the search word just has to appear in the text being searched?
What is the value in RecordID when the query is created? What creates it / updates it?
Have you tried stepping through the code and looking at the contents of the variables?
Your code is incomplete. You need to add
* add your environment here
One of the few things I remember from doing COBOL is that the order of the divisions is I(dentification) E(nvironment) D(ata) P(rocessing) which creates the mnemonic i.e. DP, said as "That is Data Processing"
Should 'f(i, ref j);' be 'f(i, out j);'?
Are you trying to create a string with "&Hxx" texts in it, as per your description; or an array of bytes as per your sample code?
If it is the string, then you can do a simple text conversion e.g. Dim byteString As String = "&H" & inputString.Replace("-", ", &H")
If it is the array of bytes, then I'll let someone else reply as the technique is slightly harder and will need something in a 'Solution' section rather that a 'Comment' section.
I have not looked at how you are following the nodes, but there is a problem with your RegEx expressions.
1) You are enclosing your URLs in '[' and ']'. Those delimiters mean 'match any character in the list' s, for example, [www.digikala.com/camera] would match a single character the is any of w, d, i, g, k, a, l, ., c, o, m, /, or r (I've dropped duplicated characters). To match the URL as a string, drop the '[' and ']'. You can keep the '(' and ')' if you want to use subgroups.
2) As you are not using '^' and '$' to anchor at the start and end of the texts, some of the tests will not givemn what you expect e.g. your regex9 will catch anything that also matches regex10 through to regex15 as it contains a subset of all of them.
Also, your 'if' statements are wrong. 'if (res1=true)' will assign the value true to res1 and then the 'if' will see if res1 is true. Ir will always be true as you have just assigned it the value of true. To compare, use '==' e.g. 'if (res1==true)', but since 'if' is comparing the expression for truth anyway, all that you will really need is 'if (res1)'. Ditto for all of the other 'if (resn=true)' when n = 2 to 14.
Try changing your
File.WriteAllText(Path.Combine("Results" + myDate, "Bad.txt"), "listBox1.Text");
File.WriteAllText(Path.Combine("Results" + myDate, "Bad.txt"), listBox1.Text);
i.e. getting the text from lstBox1 rather than writing the literal string "listBox1.Text"
I'd be very wary of hooking into standard DLLs. You cannot know how it might affect other applications and there may be issues if the DLL changes. My only thought re Chrome / Edge etc is that most browsers have a print option to not print the background of a web page. Is it possible that some of the call(s) that you are intercepting to create your watermark are for generating the web page backgrounds that the browser option is then discarding?
I cannot answer your question, but there is redundant code in your sample. The 'if (Request.IsAuthenticated && empId != null && Id != null)' leads into a block that includes 'if (Id == null)'. If it gets to the 2nd 'if', then the 2nd 'if' then Id must not be null, so the 2nd 'if' is always false.
You cannot enter an infinite number of numbers - it would take the whole of eternity to do it. Do you mean that you can type more numbers than you want? Does it find the solution for every number that you type or just the first one that you are searching for? My guess is that it will only search for the first one and the rest will be ignored. This is because you are just filling in data into a scan buffer and your program is consuming data from the scan buffer. Data not relevant to the program (e.g. your infinite set of numbers) just sit there waiting in the buffer in case any code wants to scan them. However, if you are entering multiple numbers and each is being searched in turn, please verify that the code that you have posted is what you are running and that there isn't another loop somewhere that is picking up the other numbers.
As is, the query would find rows where column 'column' does not have any letters in the range A to Z. I guess the OP is looking for rows where column 'column' only contains the letters A through Z, which is a lot trickier. Even if the correct LIKE is used, it wouldn't eliminate anything, it just wouldn't select specific rows to be returned in the query
Also check the size of the field in the database that the data is being saved into. A large image will need a large amount of storage and (as has already been mentioned) converting to Base64 inflates the size by 1/3. If the resultant size is bigger than the max size that the field can hold then the database update will fail.500Kb will need a field that can hold 682668 bytes.
I've learnt something new today, having looked at your SQL. I did not know that the ELSE clause in a CASE was optional. I've looked it up and the docs say it defaults to ELSE NULL. I think that I'll still always put an explicit ELSE in my code just to confirm that I've at least considered the possibility; but that is the exciting thing about reading other people's code - there is always new things to discover or new ways of doing old things.
You say "in the designer radiobutton is empty". This is to be expected. The Form Designer shows the design of the form, not what happens at runtime.
Even if you can connect, you must be aware that there are many SQL Dialects and versions; so you would have to code variants for different systems.
Capture the actual error code from the 'write' and include it in your error message. Then look up the code - that should give you a clue as to what the error is.
if ((errcode = write(sockfd, sendline, strlen(sendline) + 1)) < 0)
printf("The write function returned %d\n", errcode);
Also, I suspect that you might need an '&' before the recvline argument in the read function (happy to be corrected if I am wrong).
Look closely at your transliteration, you've missed something (clue: it is in the 'while' clause).
Multi-threading is the correct way to go, but as a quick hack you can (often, but not always) get away with Application.DoEvents. If you do go down this slightly risky route, disable the Save button when pressed and reenable it when saving is completed; otherwise impatient users will keep pressing it.
The PNG has a formula like
sum = x + (x^2)/2! + (x^3)/3! + . . . + (x^N)/N!
(where I am using ^ as the exponentiation operator)
You need to understand the ! (factorial) operator and the fact that this is an infinite sequence (the N represents a sufficiently large number). Any reasonable Computer Science text book will tell you how to handle infinite sequences. Hint: Do not blithely get the terms and add them; you will need to think about the pattern between the adjacent terms. If you think about what the parts in the terms are doing, you will see why.
I think that the OP knows what is the problem with the code. His / her qn was how solutions to the problem submitted by examinees can be tested safely.
This is known as a Pivot Table. Google it - there are a lot of possible solutions for SQLServer as that does not support them out of the box. However, the solutions are not easy.
I am not sure what you are trying to achieve. Are you trying to truncate numbers at 4 dec places or to display them with 4 dec places. Please tell us the expected output and the actual output.
I have tried your code in SQLServer and your 2nd col produces zeros for all values except for 18.26 which gives 2.91038304567337E-11 which is almost zero - this will be a rounding error. Float will always give inexact values as the binary value is only an approximation of the decimal value which is something you must be aware of when working with float values (in any language, not just SQL). All of the values will have rounding errors but some will be too small to display so they are shown as 0.
As @CHill60 says, What error?
There are a million and one possible error each with different causes.
My wide guess is that you have fields EMP_NO and / or group_name present in multiple tables so Oracle doesn't know which one to use. Try using qualified names, e.g. em.EMP_NO and gi.group_name (if they are in emp_master and groupinfo respectively, otherwise adjust as required).
Or is EMP_NO numeric? In which case you may need to cast / convert to text if gi.group_members and v.DIR_EMP_NO are texts; otherwise if they are all numbers, convert the concatenated string expressions to arithmetic expressions (exact formula depends on whether EMP_NO has a constant no of digits excluding leading zeros or not).
In summary ... please supply more information as we cannot guess exactly what you arte trying to do.
I'll leave it to someone else to comment on using expressions rather than simple column names in join clauses.
How are you invoking the page? If you have it locally and are double-clicking its filename from Windows Explorer or right-clicking and using 'Run Using ...', it will load with a 'file:' protocol. This does not seem to be honoured in Edge but is honoured in Chrome. I do not know if it works in IE11 - it used to work in earlier versions of IE. If you are running it through a web server, then I cannot help.
If you are only concerned about the first two chars, why are you comparing the whole strings? Wouldn't it be easier just to check the first 2 chars if that is all you want, e.g. if (temp1 == str && temp1 == str) printf("same\n"); else printf("different\n"); ?
Minor Typo: in the list of 2 digit combinations, the values should be
12, 21, 15, 55, 59, 98
@OriginalGriff's solution checks the whole field in one go, so change the #().keypress to #().change (I'm not a jQuery expert) and test the field value rather than the event keystroke.
Why are you manually counting no of rows returned? You don't use the fields, so it would be better to do
SELECT COUNT(*) AS nRecs FROM prrr1 WHERE username = @Username AND pic = @Image
(this is assuming you use Nathan Minier's advice to parameterise your expression) and then just get the count directly
For ordering ascending, try changing
AND cte.[Rank] < cte.[Count]
AND cte.[Rank] > cte.[Count]
or try changing
, Models + N' , ' + Model
, Model + N' , ' + Models
I don't have SQL Server, so I cannot test either of these two possible solutions. I would be interested to know if either / both work.
Many style gurus suggest comparing strings against variables, instead of comparing variables against strings just so that compilers would catch the mistaken use of '=' instead of '=='. Viz:
if ("Manager" == UsernameTextBox.Text && "Maintenance" == PasswordTextBox.Text)
which is valid whereas
if ("Manager" = UsernameTextBox.Text && "Maintenance" = PasswordTextBox.Text)
Personnaly, I think it looks clunky and awkward. Anyone who uses that construct is already aware of the issue of confusing '==' and '=', and hence probably does not need this backward construct. Conversely, people who are likely to fall foul of '=' instead of '==' are unlikely to be ones who would use the backwards construct. But I am sure there must be a set of people somewhere that would benefit fropm this backwards construct.
Last Updated 1 Jan 1900
All Rights Reserved.