|
How can I display everything at both the console and a txt file.
|
|
|
|
|
Replace your Console.Write and Console.WriteLine calls with a calls to your own method - it can then call the appropriate Console and file system methods.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hello Everyone,
I would like to create my own barcode generator without using third party library.can i get some info on it?
|
|
|
|
|
Take a look at this article GenCode128 - A Code128 Barcode Generator[^]. This should help get you started. There are also plenty of other examples out there.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
|
Akshay_88 wrote: can i get some info on it?
Certainly. You can look at the answers you got when you posted[^] this question before.
|
|
|
|
|
CP holds 45 articles[^] with barcode in their title. I trust you read most of them?
|
|
|
|
|
Steps to creating your own.
1. Research what "barcode" means exactly. There are different standards. Initially probably best to pick one.
2. If you intend to print it then you are going to need to learn how to write code that prints an image.
3. You need to learn how to create an image in memory. This would be part of 2 but you need to create your own (rather than doing something like loading a jpeg file.)
4. Create code (like what you learned in 3) to implement what you learned in 1. So create a barcode image.
5. Print the image (4 and 2)
|
|
|
|
|
Hi all, I am trying to randomly select a character set from a list to be used in my function but I can't get it to work, below is what I have thus far.
public const string myChars1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const string myChars2 = "abcdefghijklmnopqrstuvwxyz";
public const string myChars3 = "0123456789";
private string RandomString()
{
char[] buffer = new char[24];
int i = 0;
while (i < 23)
{
int k = 0;
string S = "";
Random myRandomNum = new Random();
Random myRandomNum2 = new Random();
k= myRandNum2.Next(1,3);
S = Convert.ToChar(k);
buffer[i] = myChars+S[myRandNum.Next(myChars+S.Length)];
i++;
}
return new string(buffer);
}
I am trying to tack S to the end of myChars so that I will get myChars1, myChars2, or myChars3 randomly but it's not working. How could I achieve this? Any suggestions is greatly appreciated, thanks in advance for your help.
modified 19-Jul-12 13:32pm.
|
|
|
|
|
Hi,
ASPnoob wrote: I can't get it to work
not informative.
ASPnoob wrote: it's not working
again, not informative. you've told that already. is it compiling? is it running without exceptions? are the results not what you hoped for?
A random number generator generates seemingly arbitrary numbers; it starts at some value, which depends on the seed you give it, or the current time. Your loop creates a new instance of class Random on each iteration, they will all run with the same initial value (as your program will last less than 1 millisecond), so there isn't much randomness at all.
Suggestion: create one and only one instance of Random and keep using it over and over.
|
|
|
|
|
|
If you're using a multitude of Random() objects, how will you give them arbitrary seeds? with another Random perhaps? And what would be the point of all that?
|
|
|
|
|
|
Right. I think that is well beyond the scope of this thread though.
|
|
|
|
|
Hi Luc, thanks for replying. The compiler is saying that myChars in the following line
buffer[i] = myChars + S[myRandNum.Next(myChars + S.Length)];
does not exist in the current context.
It's probably something simple and I'm scouring my book and the web for an answer.
modified 19-Jul-12 14:16pm.
|
|
|
|
|
You're not going to find an answer.
Where did you define myChars ?? It's nowhere in the code snippet you posted.
|
|
|
|
|
The compiler is right. (It usually is, you'll get used to that).
There is no variable called myChars declared anywhere in your code.
And you can't concatenate parts of a variable name like that, you need a completely different approach to get what you want. You might store the three strings in a string array, then use a random index into that array.
PS: please don't modify a post in such a way that earlier responses become meaningless or incomprehensible. Leave the original content, and if necessary add/modify and indicate you did. Like so:
[ADDED] new information goes here [/ADDED]
|
|
|
|
|
|
Thank you everyone, your responses have been very helpful. The problem is now solved. I decided to use an idea which some of you had suggested and that is to use the index of an array to achieve what I wanted.
|
|
|
|
|
Let's say I have a simple aspx page with a text box and a button. when the text box is filled and the button click, it will proceed to another page.
Now I want to use console app to make it run auto.
How can I do that?
|
|
|
|
|
|
I am prepared for the "wrong forum", "google the answer", "RTFM" replies but I have looked and found various methods of running a VB script, C++ dll etc. but none of how to execute an exe. The exe in question looks for a driver checks the version if its below the minimum it installs the minimum, if its above it does nothing. I guess that my question can also be seen as invite to all sorts of nasty code but!
Glenn!
|
|
|
|
|
Glenn, if you download the source to MoXAML PowerToys[^] I have added an installer that performs a custom action. Load the project and look at the project MoXAML.InstallHelper to see how I have implemented it.
In the file AddinInstaller.cs, modify the Install method to do what you need. One thing though - you don't need your code to be in a separate exe - you could actually put your check code in this helper, and call it from this method.
If you need to start an external program, all you need to do is call Process.Start to run that program (passing in the name and path of the executable).
|
|
|
|
|
Hi,
Done that this raises more questions. I was hoping that there would a quick method such as Process.Start(@"Driver.exe"); my question was how to use/implement a custom action as the MSDN version assumes you are doing A and only A, oooh heck I need
Glenn
|
|
|
|
|
I'm lost now. The code I've shown you shows HOW to write the custom install step. Are you not sure about how to add the custom install step?
If so, all you need to do (after adding a reference to your custom installer project into your installer) is to open up the Custom Actions node in the installer and right click on it. Choose Add custom action from the context menu then choose the assembly that contains your custom installer. And that's it - job done.
|
|
|
|