i used to create sub procedures in vb6 under tools/ add procedure. Same is not available in vb2008. how can i create sub procedure in form.

for eg.

Private Sub CmdDisabl()
Cmd_New.Enabled = False
Cmd_Amend.Enabled = False
End sub

if i type above code in form i get error

statement is not valid in namespace

if i create module and put above code in it , gives erroe

Cmd_New is not declared

how to create procedure at form level in vb2008
thanks

Member Avatar for Unhnd_Exception

What kind of error do you get in the form when you type that??

commented: -=1 because I dealt w/an Unhandled Exception for about an hour earlier, not fun at all. :D -3

open your form in the design-view. Click F7 to get in to the code behind file.
You have to create your procedure inside the Class.
IE: (asuming your form name is Form1...)

Public Class Form1

Private Sub CmdDisabl()
 Cmd_New.Enabled = False
 Cmd_Amend.Enabled = False
End sub

End Class

i am getting error in class

Name 'Cmd_New' is not declared
Name 'Cmd_Amend' is not declared

why i need to declare command name againe

Thanks

Have you tried adding the Form's.Name just prior to your Cmd_New.Enabled... ?

Example: Form1.Cmd_New.Enabled = False

commented: I guess the same reason as yours. -2

adding form name has solved the problem


thanks

8 Hours Ago

>>adding form name has solved the problem

Not marking the thread as Solved, gave me a problem? and I have no problematic questions.(sigh) I would cuss you out, though it's morning and I already cussed out a neighboor; hope the previous sentence takes care of your "other" problem, not keeping it IT in an IT forum.

Other than that, glad I could help.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.