Jump to content
xisto Community
Sign in to follow this  
Aequitas619

A Few Questions Please help

Recommended Posts

Hi everyone. I have a few questions about Visual Basic.Net. Its nothing complex, just a few problems with syntax!1. First, how do you change a labels text color? I have tried messing around with forecolor etc but cant quite seem to get it right!2. Also, Id like to put a return in a label to use multiple lines of text. Something like <br> from html3. How do I include other classes? Do I use inherit?4. Lastly, how do I include math functions? Something like #include <math.css> from CPPThanks in advance for the help!

Share this post


Link to post
Share on other sites

Hi everyone. I have a few questions about Visual Basic.Net. Its nothing complex, just a few problems with syntax!
1. First, how do you change a labels text color? I have tried messing around with forecolor etc but cant quite seem to get it right!

2. Also, Id like to put a return in a label to use multiple lines of text. Something like <br> from html

3. How do I include other classes? Do I use inherit?

4. Lastly, how do I include math functions? Something like #include <math.css> from CPP

Thanks in advance for the help!


1. Forecolor is the one. I don't see why you can't.

2. Label is auto wrapping. A workaround is to use TextBox as label. Turn on Multiline, make it ReadOnly and change the cursor to Default instead of IBeam, and border to None. It should look quite like a label.

3. There's no need to include in the code. If that file is not in your project, just add it in, or link (Click the down arrow in the open file dialog, and select Link File). And that class you need should be Public, then you can just access it from any other class or module you have.

4. Math function is built it, unless you're talking about advance or complex one, which normally comes as an additional class(.vb) or library(.dll). For class, just refer to step 3. For library, you need to add it as reference

Share this post


Link to post
Share on other sites

1. First, how do you change a labels text color? I have tried messing around with forecolor etc but cant quite seem to get it right!
2. Also, Id like to put a return in a label to use multiple lines of text. Something like <br> from html

1. Try this .. Double click the label and write the code .. label1.text = red (change the color or use the color with ' like 'red') see if that helps. Else try label1.color = red .. I dont have my laptop so cant try it out, but m shure one of these combinations will also do the trick.

2. Doesnt \n work ? Never really needed a new line in the labels so this is a shot in the dark.

Regards
Dhanesh.

Share this post


Link to post
Share on other sites

It looks like this has mostly already been answered but I figured I would throw a little bit more on it.1. Label1.ForeColor = Color.Aqua as an example.2. Label2.Text = "First line" + vbCrLf + "Second line"The secret here is the vbCrLf (carriage return, line feed). One of my first problems in VB was finding the “/n” which this is it. Another way is to use Environment.NewLine. I think this is the perfered Microsoft way as this will be compatible across all platforms but I have never had any problems with vbCrLf.3. The way to inherit is to use the inherit keyword directly after the class definition. From my experience you should not have to use this very often. When I do it is usually creating a user defined control that is derived from a similar control. For example, a text box that already has a particular phrase in it.4. As said before most of the basics are built in. For some of the more exotic function you can use “Imports System.Math”.

Share this post


Link to post
Share on other sites

From what I remember about editing graphics, all objects have a backcolor option. Set this with either Color.*, with * being a color, or use the hex equivalent of that color. For your new line issue, input your label text and insert Chr(13) where you want your new line inserted.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.