Private Sub dgvstock_CellValidating(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles dgvstock.CellValidating
Dim s As String
s = Convert.ToString(dgvstock.CurrentRow.Cells("Description").Value)
Dim a As Integer = s.IndexOfAny("0123456789".ToCharArray())
If a >= 0 Then
MessageBox.Show("Enter only characters")
Ah I see. Well the CellValidating event validates the content of cell that has just lost focus (well that's the way I interpret it anyway). Therefore, you have to check which cell is being validated and then do the validation.
So what I do (and this isn't necessarily the best or the only way) is use a select statement to determone which cell is being validated and then do the required validation. Something like:
Select Case dgvstock.Columns(e.ColumnIndex).Name
-- do your validation for the description column here --
I have this code and I need to add a shortcut key (CTRL+B) for this function
If I Press (CTRL+B) this function should be executed..
How to add it ...? and how to call this function?
Here is the part of the code and I have also attached full source code with it..
Private Sub Brwse_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Brwse_Button.Click
Dim RetVal As Integer
Dim FolderName As String
FolderName = ""
RetVal = FolderBrowserDialog1.ShowDialog()
FolderName = FolderBrowserDialog1.SelectedPath
If Not (Trim(FolderName) = "") Then
LogLib_TxtBox.Text = FolderName
+turn keypreview on (property of the form)
+in the keydown_event, add the code to test if the control key is pressed and the b key is pressed via the 'e' argument of the routine
+if so, call brwse_button_click(nothing,nothing)
typically however, you also give the user a "hint" that the hot-key is available via a menu item or someother means. if you use the menu item, then you can assign the hot-key there.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
In addition to what nlarson said, move that code you want to call to its own sub instead of putting everything in the button handler. This will allow you to call the code from anywhere in the form without passing in arguments you don't have.
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
I'm new to the programming world, but not the computer world. Anyway, I've just recently downloaded Visual Basic 2008 Express Edition, and so far I love it. However, I came across an old source file that's opensource on SourceForge.net and downloaded it. I was trying to upgrade the Project1.vbp using the VB2k8 Express upgrade wizard when it told me that the upgrade failed because the mdlFormHandling.bas file was missing. The problem is, I went into the folder and looked and it's not missing. It's right there. I took some screenshots to show you if anyone could please, please, please, please help me. I'm just a lowly college kid! No money for the big guns yet! >.<
I've got and tried to track through that filepath and.....nothing. I've done a system wide search and I don't have a file labelled "VB98" to try and find and get into to follow the rest of the path. I'm completely at a loss here. I thought that maybe it was looking for a library I didn't have so I went online and downloaded the libraries for VB2k8EE from microsoft's website and installed them, but unfortunately, I'm still having the same trouble....I can't copy the file's into the location because the location it's looking for them in doesn't seem exist and I'm not even sure what the full filepath would be because it gets cut off with the "\...\...\...\VB98\" and etc...I thank you for your response though.
thanks =)) its solved. as i run the code in macro it does not work but when i change it to a button it works =)) thanks for all the helps guys.
anw can i have some comments, my boss wants me to programe a excel programe to help them generate report. do you think i should do in spreadsheet or forms. which one would be presentable and more interactive??
I tend to use the Forms, sometimes just have a macro to call it.
(eg, Ctrl Q to call the form).
I find them easier and more adaptable.
Obviously for simple things like a column transfer or a set of create and save Sheets etc a Macro is easier, especially as you can use the recorder.
It really is a matter of choice, but I think the Forms a) look more professional, and b) imply you have done more work(even if you haven't), so it is better for workplace kudos.