|
You can use TextChanged event of your textbox for checking if the text entered conatins no numeric characters. If there is specific format of the account numbers, look into masked textbox.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I know, I checked this in keypress, but I want that the letter values aren't shown in textbox after the msgbox occures.
Like:
If Char.IsNumber(e.KeyChar) then
'Show numeric values
Else
'But here letter value is showed
MsgBox ("Please enter a numeric value: " ,vbinformation)
tb500.Focus
Exit sub
End If
Thanks
|
|
|
|
|
Well, do what I told you. Your code is broken for two reasons
1 - it doesn't cancel the unwanted keypress
2 - it doesn't let the user use the arrows or delete keys
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
As CG said, you have not cancelled the last key press. Along with this, take care of the case when user paste's anything in the textbox both trough mouse and keyboard.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I understand what to do, but since I use vb.net only for a few weeks (I always used vb6, other solution for this problem), can you help me with this code
Thanks
Luc
|
|
|
|
|
Nobody who can help me please?
|
|
|
|
|
Luc Baetsle wrote: But if a letter is entered, the error I created is given, but after the letter is visible in textbox also.
What error ?
You should also use char.IsControl to check if it's a backspace, etc. And if it's neither, set the Handled property of the eventargs to true. I believe you need to do this in the KeyPress event.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
That wont fire in case user pastes text in the textbox through mouse.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I didn't know that, but, either way, any code that turns text into a number should use tryparse, and if that's the case, some extra code should be written to deal with it, but the KeyPress event is the best way to handle the user typing into the control.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: some extra code should be written to deal with it
And where would you write that? In the TextChanged or the MouseDoown event, hence what I feel is, it is better to keep the check in one place instead of two.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Well, you could do it all in TextChanged, but at that point, you have ALREADY accepted an unacceptable character, therefore, this solution is unacceptable if you want a clean implimentation, where pressing a letter or other non number/non control character, just does nothing.
Every implimentation I've ever seen, does it the way I'm suggesting. I don't even bother handling mouse pastes, if people want to do that, that's their fault. My code will still detect a non number and show a message accordingly.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Why not in keypress event? Or will a copy / paste not be recognized then?
|
|
|
|
|
Text box named "origens"
Use this code
Private Sub origens_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Then ' Rejects all ascii < 0.
KeyAscii = 0
Else
If KeyAscii > 57 Then
KeyAscii = 0
End If
End If
End Sub
|
|
|
|
|
Private imageArray() As Image
For i = 0 To List1.Items.Count - 1
imageArray(i) = Image ' Image is a Image which format is metafile
Next
The above code work properly but imagearray() is not storts images data.
So the error is generated on imagearray(i).width.
error is "Parameter is not valid"
Thanks
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: The above code work properly but imagearray() is not storts images data.
What makes you think that ?
eg_Anubhava wrote: imageArray(i) = Image
This means that all the items point to the same image, if you change one, they all change. I suggest you read a basic book on VB, esp read about value types and reference types. I'd guess you set Image to null or otherwise dispose of it, thus breaking all the many identical references to it that are in this useless array.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
i want to be Array of Images.
If you can think then I Can.
|
|
|
|
|
I know that. But, you're making an array where all the images are the SAME object. Read my post again. Why do you want all the images in the array to be the same anyhow ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
No sir its only a example. I am creating diffrent images array.
If you can think then I Can.
|
|
|
|
|
So you want us to help fix your code, but the code you posted is NOT the code you're using ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
My code is same but the reason of hiding is Long Code to define.
There Createmage is a function which returns the Image of passing parameter.
Private imageArray() As Image
For i = 0 To List1.Items.Count - 1
imageArray(i) = CreateImage(i)
Next
If you can think then I Can.
|
|
|
|
|
I m new to office addin in VS 2008.
I am creating a word template in VS 2008 now i also created a ribbon button. what i want is when i click the ribbon button it should read xml file and fill the data in the template in which there is a table.
i am reading the file on the click of a button but i am not able to access the word template table in which i want to add the data since both are seperate projects (addin project and template project)
i also used the Microsoft.Office.Interop library to access the word object but i am not able to access the table object through which i want to insert the data in the xml file into the table.
any one has an idea on how to do it?
|
|
|
|
|
Hello Friends,
I have generated problem while generating Print priview (When i m printing 4000-50000 Pages).
Error is Given Below
Screen-compatible bitmap cannot be created. The screen bitmap format cannot be determined.
Actually the problem is generated by this line
Me.PrintDocument1.DefaultPageSettings.HardMarginX
In 4900 times it's working normally. But at 4913 it generates error Attempted to divide by zero.
so plese give me the solution for that.
Thanks
If you can think then I Can.
modified on Monday, November 2, 2009 1:43 AM
|
|
|
|
|
eg_Anubhava wrote: Me.PrintDocument1.DefaultPageSettings.HardMarginX
That can't be the whole line, it doesn't do anything. What's the rest of it ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
The Proper Line is
If (leftMargin - Me.PrintDocument1.DefaultPageSettings.HardMarginX) >= 0.0F Then
'Code here
end if
If you can think then I Can.
|
|
|
|
|
OK, then I guess HardMarginX must internally do some sort of division. Perhaps you need to work out what that is, with reflection, and replace it with your own code which first checks for zero ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|