|
btw, why is there a 'not' in
e.handled = 'not' char.isnumber(e.keychar)
doesn't char.isnumber(e.keychar) referring to numbers in general.. if So, why does e.handled = 'not' of it..
|
|
|
|
|
if it is a number, a space or a control character, you want the base class to handle the keypress (i.e. you want it to occur ). So, you set handled to false if it's a key you want, or true if you want to swallow the keypress, the base class sees you've handled the key press and so ignores it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Keys.Back = the backspace key.
Select case e.keychar
Case Keys.Back
Case Keys.D1
Case Keys.D2
End select
Hope it helps..
|
|
|
|
|
Hmm, another something to test out... Thanz man....BTW, whats keys.d1?
|
|
|
|
|
|
Man, I really learn a thing or two from KaptinKrunch and Christian... Respect to you both, Dudes.... RESPECT...
|
|
|
|
|
The Keys enumeration is more helpful if you handle KeyDown or KeyUp ( which recieves an instance of this enum, but won't let you swallow a keypress as you want ). The keypress event gets a char. Also, using the char.IsControl method covers all control keys for free, it's much more elegant code than a big old switch statement, although the switch statement gives you more control if you need it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Do you have a working example of that somewhere?
All I need is a simple textbox that limits its value to numeric (limiting the lenght and the number of decimals)
Ie it should accept two decimals only after the decimal point ie 0.12 and not 0.123
and also the maxlentgth is 9 then
999999.99 only
kanagaraj kumar
|
|
|
|
|
hmm. the only thing I figured out with the help of some good guys is to limit the keypress to numerical values and not the decimal values. Try opening a new thread and ask.. Sorry I ain't much of a help here, fresh beginner myself...But dun worry, the guys in here is cool and helpful, dun be shy or afraid to ask... hehehe..
|
|
|
|
|
Public Function AcceptNumeric(ByRef TextBox1 As TextBox, ByVal decLength As Integer, ByVal eKeyChar As Char) As Boolean
Dim dotIndex As Integer
Dim decPlace As Integer
Dim eHandled As Boolean
decPlace = TextBox1.MaxLength - decLength - 1
dotIndex = TextBox1.Text.IndexOf(".")
If (eKeyChar < "0" Or eKeyChar > "9") Or eKeyChar = "." Or Asc(eKeyChar) = &H8 Then
If eKeyChar = "." Then
If dotIndex > 0 Then
eHandled = True
Else
eHandled = False
End If
Else
If Asc(eKeyChar) = &H8 Then
eHandled = False
Else
eHandled = True
End If
End If
AcceptNumeric = eHandled
Exit Function
Else
If TextBox1.Text.Length = decPlace Then
If dotIndex < 0 And eKeyChar <> "." Then
TextBox1.Text = TextBox1.Text + "."
TextBox1.SelectionStart = decPlace + 1
AcceptNumeric = eHandled
Exit Function
End If
End If
If TextBox1.Text.Substring(dotIndex + 1).Length = decLength And dotIndex >= 0 Then
eHandled = True
End If
End If
AcceptNumeric = eHandled
End Function
*** Assign the MaxLength Property of the TextBox.
kanagaraj kumar
|
|
|
|
|
How can I open a new IE browser without overwriting one that is already open?
Thanks,
Martin
|
|
|
|
|
Hey there,
I have an application (which had been written in VB) which lists the following menu options "File" " View" "Help" etc. And ofcourse within each of these is a further list of options. I want to write my application which will automatically nagivate through the menu of this other application ... As an example...suppose I want to go to View->Text Size -> Normal, I can do so through my application at the click of a button.
Is anyone aware of the kind of messages I could send or provide an example of any such code you may have.
Regards,
Abhishek
|
|
|
|
|
For example, a textbox 'texbbox1' has been placed in a form. in the following code:
Dim str as String
str = "textbox1"
....
how to access textbox1 through variable "str" ?
Thanks a lot!
|
|
|
|
|
Hello,
To get the text from a textbox and set it to your string variable, you could use:
str = TextBox.Text
Or
Dim str as String = TextBox.Text
To set a TextBox's text from a variable, you would use:
TextBox.Text = str
I hope this helps,
Mitch
My sig:
"And it is a professional faux pas to pay someone else to destroy your computer when you are perfectly capable of destroying it yourself." - Roger Wright
Get Perpendicular! (Hitachi Storage)
My CodeProject Blog
Most recent blog post: April 11
|
|
|
|
|
Was the textbox put on the form at runtime or designtime. if it was as designtime then use the control name and not the variable to access it.
Otherwise, I would put a form level variable of type textbox to hold it. If there are going to be alot of runtime controls added, make an arraylist and add them to that.
However, the only way I know of to get the control in this case is:
Dim tb as TextBox<br />
For Each tb in me.Controls<br />
If tb.Name=str Then<br />
exit For<br />
End If<br />
Next
tb should be the TextBox you want.
|
|
|
|
|
I would like to read in the contents of a text file and split each line into and array.
fileContents.Split([what goes here?])
This is similar to what Dave helped me with yesterday but I just can’t figure out how to split at the end of each line.
Also, (hope this isn’t s stupid question) where do I go do see all of the possible actions that I can take with Split or any other function?
Thanks
Brad
|
|
|
|
|
fileContents is a String, so you would want the documentation on all the methods that a String has. Here[^] on MSDN.
As for your split statement, try:
Dim contentArray() As String = fineContents.Split(Environment.NewLine)
or
Dim contentArray() As String = fineContents.Split(ControlChars.Cr)
or
Dim contentArray() As String = fineContents.Split(ControlChars.Lf)
... depending on your text file format.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That's great! I always forget about MSDN.
Thanks again Dave.
|
|
|
|
|
I'm in the process of migrating an app from VB6 to VB.NET. I'm not at a point where I'm trying to pull data from an Informix database using ODBC and datareaders. The problem I'm having is that it's only coming back with one row. When I execute the exact same SQL statement on the server, I get 127 rows.
Here's what I've got:
================================================================================================
GetAccounts = New Collection
rs = RunSQLReturnRS(sqlReader, "select unique name from edipro_send_recv where name not matches '997*'")
Do While rs.HasRows()
GetAccounts.Add(CType(rs.Item(0), String))
rs.NextResult()
Loop
================================================================================================
Public Function RunSQLReturnRS(ByRef sqlReader As OdbcDataReader, ByRef strSP As String, ByVal ParamArray params() As Object) As OdbcDataReader
Dim cmdSql As OdbcCommand
Try
cmdSql = New OdbcCommand(strSP, DbConnection)
cmdSql.CommandType = CommandType.Text
RunSQLReturnRS = cmdSql.ExecuteReader(CommandBehavior.Default)
Catch ex As Exception
MsgBox("An exception has been thrown in the the Database.RunSQLReturnRS function." * NewLine() & ex.Message, MsgBoxStyle.OKOnly, "Error: Exception Thrown")
End Try
End Function
===============================================================================================
I would greatly appreciate any assistance with this. For the life of me I can't figure out what to do next. BTW... the connection is opened and closed in different Sub's under the identity of DbConnection.
--In a world without fences, who needs Gates?
|
|
|
|
|
|
SignMan359 wrote:
CType(rs.Item(0), String))
This code will only return the first row of the result set. You might want to iterate through the result set to get at the other rows. Try setting a breakpoint on this line and look at the rs object in the debugger to see that it really does contain more than one row.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am trying to use the Code Access Security Policy Tool (Caspol.exe) to set my .net console app permissions. When the following is run from command line:caspol -machine -addfulltrust C:\Program Files\Utility.dll
I get this error:
Microsoft (R) .NET Framework CasPol 1.1.4322.573<br />
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.<br />
ERROR: Unable to load assembly<br />
Usage: caspol <option> <args> ...<br />
caspol -af<br />
caspol -addfulltrust <assembly_name><br />
Add full trust assembly to policy level<br />
What needs to be done to resolve this error? Second question is there a better way of scripting the setting of trusted assemblies? Thanks,
Jason W.
|
|
|
|
|
Why does that path you specified look like it's bad?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You might also want to put the full path to the assembly in quotes so it's not parsed up as two seperate arguments:
caspol -machine -addfulltrust "C:\Program Files\Utility.dll"
Are you sure this is the correct path?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello coders,
I have been designing an application which contains a class called table.
There is a property called RelatedTables whose type is also a collection of tables ( I have created an extra class called TableList which extended from the ArrayList class )
In runtime, I do assign the selectedobject property of a propertygrid to a new instance of the table class, like below
dim p as new Table
PropertyGrid1.SelectedObject = p
As we all guess, the property grid will be filled with the properties of the class. As I mentioned there is a property called RelatedTables which is a collection of the Tables. I would like to add items(tables) which have been created before (in run time), to collection (RelatedTables)
How can I do that?
Thank you.
Best Regards
Emre YAZICI
|
|
|
|