|
hi Nilish , use followin code on keypress event of text box
If( (Not System.Char.IsControl(e.KeyChar)) And (Not System.Char.IsDigit ( e.KeyChar ) ) ) Then
e.Handled = True
End If
Hope this help
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
but where it is saying that on backspace key press i am making the e.handled=false.
|
|
|
|
|
hi Nilish,
note following line
not System.Char.IsControl(e.KeyChar))
Here IsControl include checks for all control key like Del,backspace etc.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
Put this code in key press event of the textbox which has to control the input....
If Char.IsLetter(e.KeyChar) Then
e.Handled =
True
MessageBox.Show("blocking alphabets,plz enter only Numerics")
End If
If Char.IsNumber(e.KeyChar) Then
e.Handled =
True
'MessageBox.Show("blocking numbers,plz enter only Alphabets")
End If
hope this vl be helpfull to u
Regards
Bino Varghese.
|
|
|
|
|
actually i wanted to allow typing for 0-9 and for backspace key
for 0-9 have been implemented
but for back space to happen , still there exist a problem.
i don't know the code.
-- modified at 6:22 Friday 4th May, 2007
|
|
|
|
|
hi NIlish ,
i m not 100% sure .but try these values
BackSpace Key Value -8
Delete Key Value-46
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
Hi all,
Does anyone know if the trigonometry math functions return in degrees or radians and if it does the math in radians how do you convert from radians to degrees? (using VB.net 2005)
Thanks
-- modified at 21:00 Thursday 3rd May, 2007
There are 10 types of people in the world: those who understand binary and those who don't
|
|
|
|
|
ummoops wrote: Does anyone know if the trigonometry math functions return in degrees or radians
It will return in Radians.
ummoops wrote: how do you convert from radians to degrees?
Use:rad*180/3.14
Regards,
Arun Kumar.A
|
|
|
|
|
Thanks
There are 10 types of people in the world: those who understand binary and those who don't
|
|
|
|
|
hi,
i would like to read the user name and the password from an ini file in vb6 and run the application in the context of this account (the platform is W2K or WXP). Can any one give me a clue how to accomplish that or what api do i need?
Many thanks for suggestions,
andreas
|
|
|
|
|
I think you're looking for the Win32 API function CreateProcessWithLogonW[^].
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
yes,this is the one, thanks
|
|
|
|
|
I have an array of a structure similar to below:
Public Structure MyStructure
Public MyString as string
Public MyInt1 as Int
Public MyInt2 as int
end structure
Dim StructArray ()
I want a function that will sort the data by the MyString field.
Any suggestions?
Thanks in advance!
David Wilkes
|
|
|
|
|
You can use the sort method found in the Array class. You can implement IComparable in your structure. Basically this allows objects of type MyStructure to be compared. Here is a simple example.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim people As Person() = {New Person("Bob", "Smith"), New Person("Chris", "Adams")}
Array.Sort(people)
For Each p As Person In people
Console.WriteLine(p.FirstName & ":" & p.LastName)
Next
End Sub
End Class
Public Structure Person
Implements IComparable(Of Person)
Public FirstName As String
Public LastName As String
Public Sub New(ByVal first As String, ByVal last As String)
FirstName = first
LastName = last
End Sub
Public Function CompareTo(ByVal other As Person) As Integer Implements System.IComparable(Of Person).CompareTo
Return String.Compare(Me.LastName, other.LastName)
End Function
End Structure This will sort alphabetically by the LastName field. If you want to sort in descending order you could first call sort to put them in ascending order and then call array.reverse(YourArray) to put them in descedning order. There are other ways to allow for multiple different sorts. If you want to learn more about it try looking up the interfaces Icomparer, and Icomparable.
|
|
|
|
|
I am trying to see if there is way to use the TimeSpan class to see if one timespan overlaps another. Maybe I am using the wrong class. For example, if I have a start date of 1/1/2007 and an End date of 4/1/2007 I want to know if that range overlaps another (example: 11/1/2006 to 3/1/2007) And if it does, by how many, minutes, days... etc...
Does any one have any ideas?
Thanks!
|
|
|
|
|
Do like this:
if s1>s2 and e1<e2 Then
s1-e1 occurs inbetween s2-e2(So, Overlapping=e1-s1+1)
elseif s1<s2 and e1>e2 Then
s2-e2 occurs inbetween s1-e1(So, Overlapping=e2-s2+1)
elseif s1 > s2 and s1 < e2 then
Overlapping=e2-s1+1
elseif e1>s2 and e1<e2
Overlapping=e1-s2+1
else
Overlapping=0
Use appropriate classes to compare 2 dates.
Regards,
Arun Kumar.A
|
|
|
|
|
Hi there,
I've been messing with the DataGridView component and it's really quite cool what you can do with it. I have it working for the most part, apart from one thing. I can't seem to get filtering working. The code I have is fort testing purposes only, basically just to get to know how to work with the DGV. I did notice that bSource.SupportsFiltering was set to False and I have no idea how to change that.
Private Sub Dialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bList As New System.ComponentModel.BindingList(Of ListItem)
Dim bSource As New BindingSource()
bSource.DataSource = bList
' ListItem has Name, ID and Important properties, which are String, Integer and Boolean
' respectively.
bList.Add(New ListItem("Item 1", 1, True))
bList.Add(New ListItem("Item 2", 2, False))
bList.Add(New ListItem("Item 3", 3, True))
bList.Add(New ListItem("Item 4", 4, False))
DataGridView1.DataSource = bSource
DataGridView1.ColumnHeadersVisible = False
' This makes sure that only 'Important' and 'Name' are shown and displayed
' in the correct order
DataGridView1.Columns(2).DisplayIndex = 0
DataGridView1.Columns(1).DisplayIndex = 1
DataGridView1.Columns(0).DisplayIndex = 2
DataGridView1.Columns(0).Visible = False
DataGridView1.Columns(2).Width = 20
DataGridView1.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
DataGridView1.GridColor = Color.White
DataGridView1.RowHeadersVisible = False
DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bSource As BindingSource = DataGridView1.DataSource
bSource.Filter = "ID == 2"
DataGridView1.Refresh()
End Sub
Basically, to test the filter, I wanted to press a button and then apply the filter and have the DGV display only the results of my filter action. I am sure that once I get the hang of the filtering, I can implement it fully in my main app. Does filtering just not work when using a BindingList as your data backend?
Gr,
Mightor
My sig was stolen by a blind monkey.
|
|
|
|
|
You can't change the SupportsFiltering property. It's a readonly flag that tells you if the datasource the BS is bound to supports filtering. Since you're using a List, no, you can't do filtering. You have to use a data source that DOES support filtering, like a DataSet or DataTable, most likely fed data by an Access or SQL Server database.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Thanks. I've now implemented it with a DataTable which is fed by an XML file downloaded from the Web. It works a treat.
Gr,
Mightor
A diseased chipmunk hid my sig.
|
|
|
|
|
Hi,
I am in the process of converting a VB.Net 2003 to VB.Net 2005 and have come across some errors. Here is one and has anyone come across it and how was it solved.
Private Sub SomeSub(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click
Select Case sender.name
Case "Button1"
'Do Something
Case "Button2"
'Do Something
Case Else
'Do Something
End Select
I get this error....
Operands of type Object used in expressions for 'Select', 'Case' statements; runtime errors could occur.
|
|
|
|
|
Easy. sender is passed as Object , which can be anything, including an object that doesn't have a Name property.
Test, then Cast sender to the object type you expect it to be, like Button in your code:
Private Sub SomeSub(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click
If TypeOf sender Is Button Then
Dim s As Button = DirectCast(sender, Button)
Select Case s.Name
Case "Button1"
' Do something
Case "Button2"
' Do something
Case Else
' This should never happen, but then again...
End Select
End If
End Sub
Doing this isn't a good idea. Simply renaming a button can cause your code to fail and be pretty difficult to track the problem down. Break your button handlers in their own methods and you'll increase your codes maintainability.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Thanks for the speedy response. Now works a treat.
May have some other questions for the forum as my conversion goes on. Could be good as I imagine loads of other people may ask the same questions.
Thanks again.
|
|
|
|
|
Just a quick question,
What would the syntax be if the handle is KEY UP or MOUSE or DOUBLECLICK?
Would it be the same?
|
|
|
|
|
Same thing. You have to cast the sending object to a type that you expect. It doesn't matter which event the sender fired, just what type the sender is.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Sorry to hassle you but what would it be for keyup, doubleclick or mouseup. Tried a couple of things but no luck. Works perfect for checkbox, button etc. Must be a Friday thing.
|
|
|
|