Solved

vb.net  button

Posted on 2004-09-09
13
182 Views
Last Modified: 2010-04-17
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,
Anchor;
and I did this O&K and it doesn't add the line Under the K like it use too.




0
Comment
Question by:peanut1010
  • 6
  • 4
13 Comments
 
LVL 5

Accepted Solution

by:
tzxie2000 earned 20 total points
ID: 12017124
put the form.acceptbutton to your OK button is ok
dialogresult means that if you call the form by
form.showdialog()
you can check the return result
if (dialogresult.OK=form.showdialog()) then

... //want you want to do
end if
0
 

Author Comment

by:peanut1010
ID: 12018712
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


anyways
dim frmform2 as new frmform2
frmform2.show

is that right.

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

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

is that correct??
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12018853
the different between show and showdialog is that

dim myform as form1
myform=new form1
myform.show
myform.showdialog

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
myform.mdiparent=me
myform.show

and next do you test acceptbutton?

0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12018875
by the way
if you want to and an hot link(I say this to others) O&k in button.text,it is working.
0
 

Author Comment

by:peanut1010
ID: 12019747
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.


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:tzxie2000
ID: 12019854
let's compare ByVal with ByRef
sub test
  b=1
  c=1
  a(b,c)
  messagebox.show(b)
  messagebox.show(c)
end sub
sub a(byval b as integer,byref c as integer)
  b=b+1
  c=c+1
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.
0
 

Author Comment

by:peanut1010
ID: 12020392
values meaning number???

Because I have subs like this
click on button1 and runs this code
test("1")


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

0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12020420
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
0
 

Author Comment

by:peanut1010
ID: 12020641
so is the way I am doing my sub ok then???
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12022810
the sub is ok
but it will not show the effect of byval and byref
you can debug it and following the run step
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now