Hey,

I have created one digit 7-segment screen in vb.net, which works fine, but I need several digits to show. How can I show the screen in multiple instances, which can be controlled separately?

The form code is in attachments.

Any suggestions appreciated!

I got an error trying to load the design file, however it looks like all your doing is using a series of controla to show a digit. Putting more controls on your form should be easy, however your might want to think of a naming convention for the controls(i.e. Digit1Seg1, Digit1Seg2, etc.), this will allow you program each digit separately. This is of course the simple way. There are more efficient, but more complicated, ways that involve grouping the controls together so that you can use a loop to access each one, rather than hard coding each one individually.

however your might want to think of a naming convention for the controls(i.e. Digit1Seg1, Digit1Seg2, etc.)

Yeah, this is what I thought first about, but the whole thing would come out kinda messy.

There are more efficient, but more complicated, ways that involve grouping the controls together so that you can use a loop to access each one, rather than hard coding each one individually.

That is what I was actually interested in. Can you give me an idea how can I do such a thing? Thank you.

First off, COOL project.

I think what you want is to define this as a user control so that you can place multiple instances on a form. I apolgize for totally rewriting your code, but it looked like to much fun to play with for me not to turn it into a control I will use.

Here is the modified project. I did not impliment your track bar, but I think you can deal with that.

Edit: I forgot to mention, just rebuild the project. The Digit control should showup on your toolbar.

commented: Excellent post. +12

This looks fantastic! Glad you found the idea interesting.

I have one question though. Is is possible to integrate the control in the Global Assembly Cache so I won't have to include the file in every project anew?

I have one question though. Is is possible to integrate the control in the Global Assembly Cache so I won't have to include the file in every project anew?

Sure, just start a new Control Library project and copy the usercontrol code to it. Here is a link to how to add an assembly to the GAC.

http://msdn.microsoft.com/en-us/library/dkkx7f79%28v=vs.90%29.aspx

Thanks, I added the assembly successfully.

While examining how the display is working, I thought about creating properties for the segments color when turned on and off. Tried a few things but I couldn't find a way to do so. Can you take a look on the code again? Thank you!

Can you take a look on the code again?

Good thing I did. Found some serious logic errors. Good example of that just because it worked, doesn't mean its right.

Now has color setting capabilty and rounded corners. Yes, I had to tweak it. ;)
I really want to use a pointed crystal shape, but writing a custom shape is will take some time. I also add some stuff to make it nicer to use a control. Feel free to ask if you have questions.

Please close this thread if your happy with it.

You are awesome! Right now I'll use it as is.

One last thing: My VB skills are not high enough to build something like this, so please list a few things that are important to learn to be able to do so.

Thanks again.

Well here's one las t update. I added a few for comments to help you uderstand whats in there and cleaned up the code.

As far as things to help you learn.

  1. First and of high important. Set Option Strict On, Option Explicit Off, and Option Infer Off as defaults in your settings. You may hate that you have to do some extra typing, but it will save you much more time in debugging. It will also make you think about why VS is now saying that you should not do some code in a certain way.

  2. Your search engine is your friend. If you are looking for help on a certain keyword or method, try searching for "msdn what you are looking for". This used to mainly take you directly to the documentation page, but I noticed that lately, it pulls more from the microsoft forums. Both can be useful and bad at the same time. If you are looking at the documentation, scroll to the end of the page; that is where the community feedback is and there is often corrections and sometime sample code placed there.

  3. Let VS help you zero in on possible things to investigate further. Right click on methods and click "Go to definition" This helps see more information about the method and can help think about what to go looking for.

  4. Sample code is always good, but you will most likely for the source code as C#. This is OK, because in reality you are doing .Net programming and VB is just the language you speak. Get a C# to VB converter. I like the Instant VB one by tangible solutions. It will limit you to 100 lines to convert, so delete blank lines. You can also have multuple states per line. Sometime you can end reducing an entire example to one line. The nice thing is that the converter puts the line breaks back in.

  5. Don't be afraid to change stuff and see what happens. It only costs you time and electricty and is a good way to learn through trial and error.

  6. Now for the most important. Keep up with your current mindset of wanting to learn. Too many people get a piece of code that works and never bother to learn how and why it works. Once you understand it, see if you can improve on it and make it your own.

Good luck and have fun.

commented: Good advice +12

Wonderful. Thanks for the update!

Now I am closing this thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.