PDA

View Full Version : n00best Visual basic question ever



El Barto
25-04-04, 14:18
I just wanna know how do you link from one form to another form in the same project in VB, using a button? This probably is a very n00bie questrion, but I am one big n00b at VB.

MrChumble
25-04-04, 14:22
Do your own coursework you lazy slag :p

AlphaGremlin
25-04-04, 14:22
What, so like display it over the top of another?

Inside your buttons Click event (Eg: Button1_Click):
Form2.Show Me, vbModal

The "Me" part means that the new form will always be on top of the old one.
The "vbModal" part means that you can't go back to the old form without closing the new one.
Change "Form2" to the name of your window, and you're set! (Don't miss the dot (.) between the name and the "Show")

AlphaGremlin

El Barto
25-04-04, 14:57
Form1.Show(me, vbmodal) is what I typed in (the brackets got put there by VB), the only problem is that is under lines vbmodal with a blue line saying "Name 'vbmodal' is not declared." Any ideas?


Do your own coursework you lazy slag :p
If I did that I'd already have failed my course =O

AlphaGremlin
25-04-04, 15:01
Er... what the hell version of Visual Basic are you using?! I've used VB 5 and VB 6, and neither put brackets in!

Even if I put the parameters wrong off the top of my head (it's actually vbModal, Me)...
:wtf:
AlphaGremlin

El Barto
25-04-04, 15:04
Er... what the hell version of Visual Basic

Visual Studio .net 2003 I belive it is called. Still comes up with the same statment as well, the "Name 'vbmodal' is not declared.

Omnituens
25-04-04, 15:16
create the button

dbl click it

type in
(Current form).hide
(new form).show

just remember to enter the form names and that should work

EDIT:

on the new form you'll have to add a back button to go back to the other form, just use the code above and swap the form names over

El Barto
25-04-04, 15:26
create the button

dbl click it

type in
(Current form).hide
(new form).show

just remember to enter the form names and that should work

EDIT:

on the new form you'll have to add a back button to go back to the other form, just use the code above and swap the form names over

I tried that I typed

Form1.hide()
Form2.show()

in the button provate sub part of the code (dbl clicking on the button). It still under line it but says "Referance to non-shared member requires and object referance." VB added the brackets after the thing you said 2 type, and the forms are called form1 and form2

Omnituens
25-04-04, 15:30
you tried the help files? look at hide and show to see their usage

i dont have to use brackets in VB6

funkeymonkey
25-04-04, 15:53
I am working on a vb prog atm for my uni course work. Ill just rip a bit out of mine so u know it works. Double click on your button and stick this in there.

frmMainmenu.Hide
frmQuiz.Show

I never have used brackets. Just change the frmMainmenu and frmQuiz to the names of your forms.

You could also try it this way.

frmMainmenu.visible = false
frmQuiz.visible = True

El Barto
25-04-04, 16:16
Still says "Referance to non-shared member requires and object referance." I can't get rid of the brakets at the end of it, it just keeps putting them back in, not found any thing in help yet.

funkeymonkey
25-04-04, 18:27
Sounds like you have change some setting someplace in your copy of vb which is fucking things up. I dunno what you could do, i guess you could install and then reinstall vb? Would set everything back to their default settings.

Mines all default settings, except for what i put at the top of every program. At my uni we have been taught to put Option Explicit at the top of every program. Does somthing like checks that all varibles are defined (i think) dunno if it will make any difference or not.

gl

petek480
25-04-04, 18:34
Still says "Referance to non-shared member requires and object referance." I can't get rid of the brakets at the end of it, it just keeps putting them back in, not found any thing in help yet.
do

dim f as new (name of the form)

f.show()

FBI
25-04-04, 19:48
I just wanna know how do you link from one form to another form in the same project in VB, using a button? This probably is a very n00bie questrion, but I am one big n00b at VB.I think everyone else doesn't get your question or perhaps they do and I don't.

Your trying to link one form to another, IE call the command button's "click"
events from another form?

Well first of all change the events that you want to link to another form to
"Public" instead of private. Private makes the code local to that form and not
to others, public allows the information to be shared across the project persay.

Also, make sure both forms are loaded in memory because by the looks of it,
it can't find a reference to the memory for the form because it hasn't been
created yet!.

In form1's Form_Load event, put Form2.Show . then on form2's Command1_Click
event, change it to Public instead of private.

Now on form1 make another command button and do Call Form2.Command1_Click()

Hope this helps :P

edit: feel free to contact me for help using the icons under my name, i'm 8
year hardcore vb progger, it took me a while to move to delphi and c, vb is
like neocron to me :)

Parad0x -FBI

rob444
25-04-04, 20:18
You got Visual Basic 6/7 or "Visual Basic .net"?

hinch
26-04-04, 10:03
think youve overlooked the fact he's using vs 2003 which is .NET

so he'll be using vb.net and not vb as you guys know it (vb.net is hugely different)

since i cant be arsed to look up vb i suggest www.gotdotnet.com and www.4guysfromrolla.com

both should have what your looking for

El Barto
26-04-04, 18:02
Neither of them help, bet its probably just me, also its VB.Net

petek480
26-04-04, 19:09
Neither of them help, bet its probably just me, also its VB.Net
Like I said, add this code to the button

dim f as new form2

f.show()

and change form2 to whatever the name of the form you want the button to bring up. this will work in vb.net.

FBI
26-04-04, 19:29
Bah, .NET...

I havn't turned to the evil side yet.... I don't recommend any of you to move to
vb.net from vb5/6. Your better off learning another language. I chose delphi, I'm
3 years into it already :P

It's vb feel/simplicity with c++ benefits and power. It filled the gaps I needed.

edit: not to mention, delphi7 comes with $10,000 worth in built-in components,
stuff you'd pay alot of money for obviously. I use most of them in my commercial
apps, so there not just stuff they throw in. Indy socket controls are constantly
updated by a third party company etc.

If anyone is really into VB, but want's to move to c++... try delphi first.
Here's some good links if your interested in reading or if your bored:

To VB or not to VB (http://www.shagrouni.com/english/software/vbnot.html)
The Case for Delphi (http://www.delphizine.com/opinion/2000/01/di200001fn_o/di200001fn_o.asp)
Conspiracy Theory: MS's .Net IS Borland's Product (http://delphi.about.com/library/weekly/aa112902a.htm)
Why Delphi? Why Not!!? (http://www.matlus.com/scripts/website.dll/WhyDelphi)


Parad0x -FBI

El Barto
26-04-04, 20:46
Like I said, add this code to the button

dim f as new form2

f.show()

and change form2 to whatever the name of the form you want the button to bring up. this will work in vb.net.

OMG, that worked =) tahnx for your help and every thing all, if I ever see u in game, expect to be sexed repeatedly =) I LOVE YOU (only on a friendly way). If any of you wanted to know this is for a Skill Manager I am writing, will be ready soonish I hope, reason I am using .Net btw is cos I need to learn it for college so using it more is better college wise.

Omnituens
26-04-04, 22:29
FBI, is Delphi like Pascal, or is that something else? i can only write in VB 6 atm, but i need to learn a new language soon, i was thinking of C/C++ because thats what my Uni course will use. i'll also have to learn to use Linux, coz we'll be using the PS2 Dev kit :eek:

and also wtf is up with your text wrap in that post? :p

FBI
27-04-04, 05:27
FBI, is Delphi like Pascal, or is that something else? i can only write in VB 6 atm, but i need to learn a new language soon, i was thinking of C/C++ because thats what my Uni course will use. i'll also have to learn to use Linux, coz we'll be using the PS2 Dev kit :eek:

and also wtf is up with your text wrap in that post? :phehe it's just my style of writting, I will try to stop, but it's a bad habbit. I
find it easier to proof read my posts in the editer field if put line breaks at a
certain point. I dunno.

Yes delphi is pascal on fire. It sucks c++/c# has become a standard because
of microsoft's ability to capitalise on their products, well hey it's microsoft I
guess... they got billions to do it. Unfortunately, universities,companies that
hire, etc mostly require C++ or microsoft products for that matter, because
they all jump on the bandwagon. Borland's products I find much better, even
the C++ ide is better, it's cleaner and again the components are great, the
abilities are endless. Delphi is crazy rad, like vb tho. with c++ power.

Shame other companies don't see the possibilities with borland, hell delphi
compilations can run on both linux and windows allowing companies to provide
broader services to other audienceses.

Maybe borlands .net will change things, time will tell shrug.

Parad0x -FBI

Callash
27-04-04, 05:34
This probably is a very n00bie questrion, but I am one big n00b at VB.
Then there is still hope for you! Abandon the evil path of vicious VB, and come into the VC++ Light!

:p

Winners don't do VB!

Seriously though, VB is only any good for application Software but gets owned by Delphi in that Segment. Everything else is territory of C++ or Java and its spinoffs. :)

hinch
27-04-04, 10:19
when .net was released i looked at vb.net and realised that the language was 99% different so was pointless learning that

so i changed to c# which is quite cool despite being too similar to java for my liking but at least its twice as fast and you can actually write games in it that do run at a sensiable speed and dont need a cray to compile.

but yeah if it isnt webbased c++ all teh way baby.