View Full Version : need help in VB.Net
monitone
July 17, 2005, 07:09 PM
I am trying to teach myself vb.net, i have some questions. can anyone help me
Firstly, does anyone have any links to good Vb.Net tutorials online? i found some site wha nuh mek nuh sense
Secondly, how do you use a main form to open a sub-form?
Thirdly, how do i exit a form e.g when i press a cancel button on a form. i tried Onload(), unload me, exit sub. none of them worked
Please and Thanks in advance
Ghetto_Nerd
July 17, 2005, 09:43 PM
Firstly the best tutorial you can find on the net about VB.Net is the MSDN Library, everything you read on the net will send you straight back to MSDN library. two other good place to start is the Microsoft visual studio .net documentation or Microsoft .NET Framework SDK documentation, these files usually come with setup program and can be access from the start menu or via the folder on your computer where you load visual studio.
Secondly: not sure if you are using MDI child form. However to open a Form from another Form you have to create an instance of the form you want to open and use that instance to open the form.
E.g
Say you have a form name FrmyourName.
To open this form from another form (in a click event, such as button or menu item) create a instance of the form like this:
dim anything = new FrmyourName ()
anything.show
whenever you click the button or menu item it will open FrmyourName.
Thirdly:
In the cancel button click even: just type the word “End” and that should take care of that.
seanbee20
July 18, 2005, 08:09 AM
One correction, issuing the END statement will end the program completely, I think monitone only wants to unload or close just the form the cancel button is clicked on.
If I am correct, then unloading the form can be done by either of the two commands below where formName is the instantiated name of your form:
FormName.Close
or
FormName.Dispose
To load a form
--------------
Dim formName as New FrmMain
FormName.Show
To close a form
---------------
FormName.Close
or
FormName.Dispose
Ghetto_Nerd
July 18, 2005, 12:15 PM
To close a form
---------------
FormName.Close
or
FormName.Dispose
You are correct.. However i was thinking that because most forms have the close button on the top right hand corner, where you can just simple close the individual form, i thought he wanted to end the program it self. thanks for the correction.
keroed1
July 18, 2005, 04:15 PM
ok i know that in vb u can set forum to be fix thus user can resize the window by pressing minimise or maximise because they are not there only the close but is present for them to click can u do that in vb.net
keroed1
July 18, 2005, 04:16 PM
also if i use main form to call a sub form for exampe a sub form that collects a user name and password can it return a value to main form for me to use. if so how
p.s giva a simple example.
seanbee20
July 18, 2005, 04:42 PM
ok i know that in vb u can set forum to be fix thus user can resize the window by pressing minimise or maximise because they are not there only the close but is present for them to click can u do that in vb.net
Yes it can, just check the properties section of the form
also if i use main form to call a sub form for exampe a sub form that collects a user name and password can it return a value to main form for me to use. if so how
p.s giva a simple example.
Simple, just use global variables.
Example, you can define your variables say in a public module.
Public username as String
Public password as String
in your sub form, you would say
username = text1.text
password = text2.text
So in all your other forms, you can get the value by just referencing the variables username/password.
Main form.
Example
lblstatus.caption = "You are logged in as: " + username
keroed1
July 18, 2005, 04:51 PM
@seanbee20
blessed at wrk right now when i get home i'll try and let u guys know wat is happening
"Yes it can, just check the properties section of the form"
can tell me directly under what field name should i look for that option
seanbee20
July 18, 2005, 05:08 PM
@seanbee20
blessed at wrk right now when i get home i'll try and let u guys know wat is happening
can tell me directly under what field name should i look for that option
Click on the form, go to the properties pages and look for two properties (minimizebox and maximizebox), set both of them to false to disable them
keroed1
July 18, 2005, 07:27 PM
Click on the form, go to the properties pages and look for two properties (minimizebox and maximizebox), set both of them to false to disable them
not sure if is my verision nothing is there for maximise and minimise
next question right the sub_form.close worked
i had set the main_form to invisible because when i am seeing the sub form i dont want to see the main form but when i am finish with sub form i want to se it again is there a way i can make it visible again i tried to institate main one and call it just like i did the sub form but that does'nt wrk
keroed1
July 18, 2005, 07:44 PM
i am usin microsoft visual basic .net 2003 if that helps
seanbee20
July 18, 2005, 07:44 PM
not sure if is my verision nothing is there for maximise and minimise
See screenshot - should be in all versions of .NET
next question right the sub_form.close worked
i had set the main_form to invisible because when i am seeing the sub form i dont want to see the main form but when i am finish with sub form i want to se it again is there a way i can make it visible again i tried to institate main one and call it just like i did the sub form but that does'nt wrk
use the show / hide methods of the form
Example:
hiding main form:
frmMain.Hide
Showing sub form
fromSub.show
seanbee20
July 18, 2005, 07:46 PM
Screenshot not very visible but I hope it helps
monitone
July 19, 2005, 04:14 AM
ghetto nerd and seanbee20 thank you for your help. greatly appreciate it. will try them now.
keroed1, good questions, u took the words right out of my mouth.
keroed1
July 19, 2005, 08:50 AM
use the show / hide methods of the form
Example:
hiding main form:
frmMain.Hide
Showing sub form
fromSub.show
ok cool i think i get he idea of the show and hide method right but ?
letes say after i hide the main and show sub form right when i close the sub form will the main form automatically be shown or will it still be hidden and if so how will i be able to unhide the main form
i tried to do this by puting and and exit button on my sub form and tried to do this
p.s. {not to sure abut the bracket part just writing out of my head}
dim m_page as new main_page()
m_page.show()
but that is not working when i did the the sub form
sim s_form as new sub_form()
s_form.show()
that worked
keroed1
July 19, 2005, 08:52 AM
or maybe the problem is that i had made main visible attribrute to false
main.visible()=false
main.hide()
is that correct method that would have made it come back up when the sub form was closed
keroed1
July 19, 2005, 08:53 AM
oh when i get home going to try to take a screen shoot for u to see ok
seanbee20
July 19, 2005, 08:59 AM
You would need to set back the main form to visible=true.
seanbee20
July 19, 2005, 09:01 AM
Here is a good mini tutorial, hope it doesn't confuse you more.
http://www.devcity.net/Articles/94/1/.aspx
keroed1
July 19, 2005, 11:52 AM
You would need to set back the main form to visible=true.
I would do this in the exit button of the sub from thanks for the tutorial i will try when i get home
seanbee20
July 20, 2005, 08:18 PM
I take it that you are now crissssss
keroed1
July 21, 2005, 08:04 AM
well not really but i tried the website and thetutorials are really good but i have been really busy at wrk so i have'nt gotten the chance to go through all the tutorilas but the hide and unhide of the main and sub forms i got to practice those and they are working properly for my project
thanks again for the website and for any future advice u are going to give me
oh by the way i planning to teach myself sqql server also have any goood web sites that i can look on?
seanbee20
July 21, 2005, 08:22 AM
This is a great site (www.functionx.com) for all your tutorial needs, they have a very good SQL Server tutorial.
http://www.functionx.com/sqlserver/index.htm
keroed1
July 21, 2005, 09:08 AM
This is a great site (www.functionx.com) for all your tutorial needs, they have a very good SQL Server tutorial.
http://www.functionx.com/sqlserver/index.htm
COOL GOING TO CHECK IT NOW
because wat i am trying to do is to get as versitall in all the softwares that i am going to have to do in final year starting in september so any good tutorials is greatly appreciated :eusa_danc
keroed1
July 25, 2005, 08:09 AM
question right seanbee the whole hiding and unhiding of the sub form and main form works to apoint for example::::
main form opens contractor_form
contractor_forms closes and main form re-apears
main form opening contractor_form **********Error message************
seanbee20
July 25, 2005, 08:17 AM
I can't really help you much if I don't know the error message
keroed1
July 25, 2005, 08:22 AM
wat do u think is the problem guys
keroed1
July 25, 2005, 08:27 AM
oh ok wheni go home i am going to run it and then post the error message
keroed1
July 26, 2005, 12:52 PM
@seanbee20
update it is working now when i re-looked at the code i saw the problem was this
the first time the sub window was open the callingform= caller but then the code the website gave me then went on to do this
callingform=nothing
wich means that after the first time any other time u tried to return to the main from the sub window there was no callingform so when i commented out that line
'callingform=nothing
everything basically sorted them self out and worked
thanks though
seanbee20
July 26, 2005, 02:03 PM
Ok cool, glad to see it is working
keroed1
August 28, 2005, 09:29 PM
question guys can i add flash into my software i am using vb.net 2003 to reate by the way for anybody who have'nt gone through the previous pages
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.