|
|
Hi, Ive made a user control and it works great but the problem is that I dont want it to display on my form when I drag it in from the toolbox. I want it to be like how the timer control works where it doesnt have a gui, as apposed to how a label control works.
Im sure im just not seeing something silly.
Thanks
|
|
|
|
|
You need to derive from Component rather than Control or UserControl
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
shot
|
|
|
|
|
Gets rid of all those nasty properties and events that you don't want too!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
hi
Is it correct to leave COM1 open all along the program ?
and close it only in exit from the program ?
thank's in advance
|
|
|
|
|
if you're using it all the time, then yes. If your program is open all the time, but you only use COM1 occasionally, then no.
|
|
|
|
|
Sure, you can treat a serial port like a file. If your app needs it, take it. And release it when you are sure you don't need it any longer. If you have multiple open-close cycles, there is a risk the first cycle succeeds, whereas a later one fails because some other app has opened it in the mean time.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Need the randomization of numbers without repeatation using c#
|
|
|
|
|
vasavi.p wrote: Need the randomization of numbers without repeatation using c#
Good. You've got the beginnings of a specification there; it needs fleshing out, but it's a decent start. What have you accomplished so far?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
here's some pseudocode
repeat
r = get random number
until r is a new unique number
remember you've seen r before
Implementation is left as an exercise to the reader
|
|
|
|
|
that may take forever.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
An easier way would be to reseed the randomizer after every call with a value greater than the last returned result. It's not a great way, but it cuts out the checking.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
When N "random" numbers in [0, RANGE) need to be unique, the range typically is small, so I prefer to put them all in a bag and use a random index to get them, one by one. So there is no need for a retry.
And the problem has no solution for N>RANGE so some precautions need to be taken in any algorithm based on retrying.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
You could also shuffle your bag and just pop the top entry each time, depending on where the bottleneck ends up being
|
|
|
|
|
That would take a Random Shuffle Generator, which isn't provided by the .NET Framework as of now.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Would that work?
Since the next random value could be less than the seed, you could re-seed with a value you've used previously.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
What I was thinking was actually using Random.Next with the starting value being the value you've just retrieved + some small amount as the starting point, e.g. Random.Next(lastVal + 1, lastVal + 100) .
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'm afraid there is no way you can tell the RNG what all the numbers are that have already been picked, so the best you can achieve is avoid repeating the previous number, not all the older ones.
Of course if all the OP wants to avoid is consecutive duplication, then your way would be fine.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Pete O'Hanlon wrote: Random.Next(lastVal + 1, lastVal + 100)
Erm, doesn't that just give you a monotonically increasing set of values?
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Yes - I'm not saying it's the way I'd do it, just that it is a way.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Yup, but the OP didn't really specify enough to say what he actually wanted, so I gave a generic, if not necessarily useful answer.
|
|
|
|
|
People ask that frequently here, have you searched the threads in this forum?
|
|
|
|
|
How many non-repeating random numbers are you going to want to get ?
What is the range of random numbers - are they integers or real.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi
The procedure below takes a name from the Numbe array and places it in a directory path to find an image file to insert into a word document. All the images are numbered 1,2,3,4.... however, when the number gets bigger than 101 then the compiler complains that the file name is invalid, the file does exist so i can't figure out what is invalid about it?
public void CreateFileColumn(ArrayList array, Array Numbe)
{
object missing = System.Reflection.Missing.Value;
object fileName = "normal.dot";
object newTemplate = false;
object docType = 0;
object isVisible = true;
Object oUnit = Word.WdUnits.wdCell;
string FilePath;
wordApp = new Word.ApplicationClass();
wordDoc = wordApp.Documents.Add(ref fileName, ref newTemplate, ref docType, ref isVisible);
wordApp.Visible = true;
wordDoc.Activate();
wordApp.Selection.Tables.Add(wordApp.Selection.Range, 1, 8, ref missing, ref missing);
wordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
wordApp.Selection.Font.Bold = (int)Word.WdConstants.wdToggle;
foreach (string part in Numbe)
{
FilePath = @"C:\Users\Jon\Documents\Nick\Chin Font Files\" + part + ".jpg";
wordApp.Selection.InlineShapes.AddPicture(FilePath , ref missing, ref missing, ref missing);
wordApp.Selection.MoveRight(ref oUnit, ref missing, ref missing);
}
}
Thanks
|
|
|
|