Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,089 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,802 people online right now. Registration is fast and FREE... Join Now!




How do you make something constantly take effect?

2 Pages V  1 2 >  
Reply to this topicStart new topic

How do you make something constantly take effect?, ^^^^^

mattisdada
30 May, 2008 - 04:39 AM
Post #1

New D.I.C Head
*

Joined: 30 May, 2008
Posts: 36


My Contributions
I have a peice of code i want to be ran constantly... how can i make it do that?

If i cant, how would i go about doing this:

I have a label, and i want to make that lable change when people put a letter in it. For example, when they put the letter X in box A the lable down the bottom changes colour and says "Letters are NOT allowed". I have about 10 text boxes on the screen. Currently, i have it on text change, but that screws up if i alernate between two boxes with letters in it and not in it....

The code im using currently to decide it is:
CODE

If Not IsNumeric(dram.Text) Then If dram.Text <> "" Then err.Text = "Letters are NOT allowed" Else err.Text = "Everything fine"
        If Not IsNumeric(dram.Text) Then If dram.Text <> "" Then err.ForeColor = Color.Red Else err.ForeColor = Color.RoyalBlue
    


And normally, i would state the above as
CODE

If Not IsNumeric(dram.Text) Then If dram.Text <> "" Then err.Text = "Letters are NOT allowed" Else err.Text = "Everything fine" and err.ForeColor = Color.Red Else err.ForeColor = Color.RoyalBlue


But it wont allow me...

This is the second VB programs im trying to make smile.gif I dont fully know the program as of yet. (The first one was an Insult Generator... it was fun and easy)
User is offlineProfile CardPM
+Quote Post

mensahero
RE: How Do You Make Something Constantly Take Effect?
30 May, 2008 - 09:34 AM
Post #2

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
hellow... well your talking about changing a label's CAPTION so that would be..

label.caption = "FAILED" .. when dealing with Labels its the caption you want to change.. add it to the textbox textChange event so that it will implement immediately..

hmm.. I'm quite confused at your last statement about textChange Screws up...
how many label do you actually have? is it 10 textbox: 10 labes or 10 textbox: 1 label..?

goodluck..

This post has been edited by mensahero: 30 May, 2008 - 09:38 AM
User is offlineProfile CardPM
+Quote Post

mattisdada
RE: How Do You Make Something Constantly Take Effect?
30 May, 2008 - 04:17 PM
Post #3

New D.I.C Head
*

Joined: 30 May, 2008
Posts: 36


My Contributions
I have attatched the image of what im trying to change(in the orange box). Im unsure of what you mean when you say caption.... as there is no caption property.

And the second code box was refering that an error came up (saying it was trying to convert to boolen, but it cant convert that staement into boolean)

Thanks for your help!

I have also attatched the whole project (its 2008).

PS: Not every box has (only two do) have any code on them. I want to get the code right on one, then apply it to all. And i only just started making it tongue.gif

This post has been edited by mattisdada: 30 May, 2008 - 04:19 PM


Attached thumbnail(s)
Attached Image

Attached File(s)
Attached File  Overclocking_Calculator.zip ( 127k ) Number of downloads: 35
User is offlineProfile CardPM
+Quote Post

mensahero
RE: How Do You Make Something Constantly Take Effect?
30 May, 2008 - 07:28 PM
Post #4

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
aww.. this must be a bad day..

I think one of us is either in the wrong forum.. are you sure you are in vb.net? well I thought you were talking about vb6..

and you said you had a Label.. well IDK in vb.net.. but label's has a caption property not a text property..

hmm.. IDK if my solution in vb6 could possibly help you because I think vb6 and vb.net are actually different... sorry..


well a IMO.. if your not forced to display label.. it is better if you limit keypress(keyInput) .. in vb6 there is a textbox event called keypress.. IDK if vb.net has a different version or name..

in vb6 something like this would work..

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub

that little piece of code could actually limit user input(textbox will only accept numbers..) well try converting that into a vb.net syntax..

This post has been edited by mensahero: 30 May, 2008 - 07:36 PM
User is offlineProfile CardPM
+Quote Post

mattisdada
RE: How Do You Make Something Constantly Take Effect?
30 May, 2008 - 08:34 PM
Post #5

New D.I.C Head
*

Joined: 30 May, 2008
Posts: 36


My Contributions
Well this is the "Visual Basic" forum.....

And what you have there is virtrully what i have..... but mine screws up:P.

For example. If i type a letter in one box, and erase it, it will detect it fine.

But if write down a letter in box 1, then write a letter in box 2. Go back to box 1 erase that letter, then go back to box 2, and erase that letter*assuming theres something infront of it) it will still detect that there is a letter in one of the boxes, even if there all erased(And the onyl way to make it detect it right again, is to make both boxes empty)
User is offlineProfile CardPM
+Quote Post

Zhalix
RE: How Do You Make Something Constantly Take Effect?
30 May, 2008 - 08:57 PM
Post #6

D.I.C Head
**

Joined: 7 May, 2008
Posts: 218



Thanked: 9 times
My Contributions
Correct, this is the "Visual Basic" forum. As in, "Classic Visual Basic". Visual Basic.NET is different and thus has its own specific forum.

I think you should try asking there. You'd likely receive much more helpful information.

This post has been edited by Zhalix: 30 May, 2008 - 08:59 PM
User is offlineProfile CardPM
+Quote Post

mattisdada
RE: How Do You Make Something Constantly Take Effect?
30 May, 2008 - 10:36 PM
Post #7

New D.I.C Head
*

Joined: 30 May, 2008
Posts: 36


My Contributions
I have a peice of code i want to be ran constantly... how can i make it do that?

If i cant, how would i go about doing this:

I have a label, and i want to make that lable change when people put a letter in it. For example, when they put the letter X in box A the lable down the bottom changes colour and says "Letters are NOT allowed". I have about 10 text boxes on the screen. Currently, i have it on text change, but that screws up if i alernate between two boxes with letters in it and not in it....

The code im using currently to decide it is:
CODE

If Not IsNumeric(dram.Text) Then If dram.Text <> "" Then err.Text = "Letters are NOT allowed" Else err.Text = "Everything fine"
        If Not IsNumeric(dram.Text) Then If dram.Text <> "" Then err.ForeColor = Color.Red Else err.ForeColor = Color.RoyalBlue
    


And normally, i would state the above as
CODE

If Not IsNumeric(dram.Text) Then If dram.Text <> "" Then err.Text = "Letters are NOT allowed" Else err.Text = "Everything fine" and err.ForeColor = Color.Red Else err.ForeColor = Color.RoyalBlue


But it wont allow me...

This is the second VB programs im trying to make smile.gif I dont fully know the program as of yet.

As well, how would i go about making it also decide on whats the highest whole number that is possible by timings x by a whole number.

I tried this, but i know it does work although im sure theres a far better way of doing it
CODE
  Dim valid As Integer
        valid = 0


        If bussR.Text * 4 <= dram.Text Then valid = 4 Else If bussR.Text * 3 <= dram.Text Then valid = 3 Else If bussR.Text * 2 <= dram.Text Then valid = 2 Else If bussR.Text * 0.5 <= dram.Text Then valid = 1

        If valid = 1 Then dramR.Text = bussR.Text * 0.5
        If valid = 2 Then dramR.Text = bussR.Text * 2
        If valid = 3 Then dramR.Text = bussR.Text * 3
        If valid = 4 Then dramR.Text = bussR.Text * 4

Thats an example of what i want it to do (just be timsable by 0.5, 2, 3, 4)

I have attatched the project. This is Visual Basic 2008 express.

This post has been edited by mattisdada: 30 May, 2008 - 10:40 PM


Attached File(s)
Attached File  Overclocking_Calculato2r.zip ( 128.95k ) Number of downloads: 23
User is offlineProfile CardPM
+Quote Post

mensahero
RE: How Do You Make Something Constantly Take Effect?
31 May, 2008 - 12:52 AM
Post #8

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
QUOTE(mattisdada @ 30 May, 2008 - 09:34 PM) *

Well this is the "Visual Basic" forum.....

And what you have there is virtrully what i have..... but mine screws up:P.

For example. If i type a letter in one box, and erase it, it will detect it fine.

But if write down a letter in box 1, then write a letter in box 2. Go back to box 1 erase that letter, then go back to box 2, and erase that letter*assuming theres something infront of it) it will still detect that there is a letter in one of the boxes, even if there all erased(And the onyl way to make it detect it right again, is to make both boxes empty)



well IDK vb.net but a little researh on syntax and this code actually is the vb.net version of the keypress event in vb6..

CODE
   Private Sub dram_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles dram.KeyPress
      
        If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
            e.Handled = True
        End If


    End Sub  


well if you use that.. textbox will only accept numbers.. so you dont need the label to tell the user what he needs to do.. blink.gif blink.gif hmm.. vb.net is quite easy.. well after my project in Java.. ill probably try it.. biggrin.gif
User is offlineProfile CardPM
+Quote Post

mensahero
RE: How Do You Make Something Constantly Take Effect?
31 May, 2008 - 12:56 AM
Post #9

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
hello.. I replied on your post in the visual basic forum but I think this is the proper place for it..


well.. as what I mentioned there... limiting textInput through keypress event is better than informing the user with a label.. so this code might work.. and I've tried it in your project..

CODE

Private Sub dram_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles dram.KeyPress
      
        If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
            e.Handled = True
        End If


    End Sub



that will make the textbox only accept numbers.. so you dont need the label..

... vb.net is quite fun and very interesting..

This post has been edited by mensahero: 31 May, 2008 - 12:56 AM
User is offlineProfile CardPM
+Quote Post

Jayman
RE: How Do You Make Something Constantly Take Effect?
31 May, 2008 - 07:48 AM
Post #10

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Topics merged. Please do not create duplicate topics.
User is offlineProfile CardPM
+Quote Post

mattisdada
RE: How Do You Make Something Constantly Take Effect?
31 May, 2008 - 08:54 AM
Post #11

New D.I.C Head
*

Joined: 30 May, 2008
Posts: 36


My Contributions
Sorry i couldnt move or delete the old one when i made it in the incorrect spot.

So if you would like, could you explain to me how that peice of code works?

And when i have no values in any of the boxes, it comes up with an error saying about not being able to convert strings into booleans.

Thanks in advance biggrin.gif
User is offlineProfile CardPM
+Quote Post

mensahero
RE: How Do You Make Something Constantly Take Effect?
31 May, 2008 - 10:48 AM
Post #12

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
well if you copy this little code in any textbox keypress event.. you'll notice how it work.. do you know exactly what a "keypress event" is?

CODE

If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
            e.Handled = True
  End If


when you finished doing that task.. try inputting text in the textbox.. what happen?

well I test the code in you project and it did work.. it forces the user to input numbers only..

well.. IDK vb.net ( I've just tried it with your project )

but I think everything is event driven.. so this error

[quote] And when i have no values in any of the boxes, it comes up with an error saying about not being able to convert strings into booleans. [/guote]

is not ACTUALLY caused by the above mentioned code..

could you give me the exact EVENT.. what are you actually doing that triggered the error.. what button did you pressed? what is the last thing you've done before the error occurs.. ?

This post has been edited by mensahero: 31 May, 2008 - 10:54 AM
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:00AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month