vb.net button

First is there a default selection like in vb6 for a button, meaning when the user hits enter it knows which button to activate.

In vb6 all I had to do is change the settings from false to true and it did it.

Also I notice several properties that are new to me for the button1:
dialogresult; what is that and how do u use it,
and I did this O&K and it doesn't add the line Under the K like it use too.

Who is Participating?
tzxie2000Connect With a Mentor Commented:
put the form.acceptbutton to your OK button is ok
dialogresult means that if you call the form by
you can check the return result
if (dialogresult.OK=form.showdialog()) then

... //want you want to do
end if
peanut1010Author Commented:
not understanding at all. What is .showdialog. Please have patience with me.

is there a difference in calling a form by .showdialog vs .show

also I call new forms like this

this is an example

dim frmform2 as new frmform2, what would happen if I did dim frmform2 as frmform2, not using the word new

dim frmform2 as new frmform2

is that right.

Also if it is a child for a form I do this

dim frmform2 as new frmform2
frmform2.mdiparent = mdi.activeform

is that correct??
the different between show and showdialog is that

dim myform as form1
myform=new form1

sugget you run this code in mainform

you can change the focus from myform to mainform when use show
you can not change the focus from myform to mainform when use showdialog
you can test it.

the two way is also right but I am using showdialog more frequence.

about the second one, I am confused about what you want. could you explain your problem more clearly.
If you want to open an mdi form
set the mdiform.ismdiformcontainer to true
and add code in new(menu item or button) click event

dim myform as frmform2
myform=new frmform2

and next do you test acceptbutton?

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

by the way
if you want to and an hot link(I say this to others) O&k in button.text,it is working.
peanut1010Author Commented:
off the subject

what does byval mean and what is the major difference between using function or sub

everyone keeps saying function returns a value, but I get values when I use a sub too.

let's compare ByVal with ByRef
sub test
end sub
sub a(byval b as integer,byref c as integer)
end sub

the messagebox will show 1/2
that means you can modify the value of c but can not modify the b's
as b is by value,just a copy of b is transfer into the sub

I do not think you can get values from sub. you may show some code.
peanut1010Author Commented:
values meaning number???

Because I have subs like this
click on button1 and runs this code

public sub test(byval Num as integer)
      todays = 1 + Num
 msgbox todays
the msgbox shows answer which is 2
end sub

byval mean anything

change your code "1" to a variant such as dim a as integer or string or anything and move the msgbox after test(a) your will see the effort
peanut1010Author Commented:
so is the way I am doing my sub ok then???
the sub is ok
but it will not show the effect of byval and byref
you can debug it and following the run step
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.