Jump to content


Photo

Visual Basic?


5 replies to this topic

#1 JT Nerf Girl

JT Nerf Girl

    Member

  • Members
  • 149 posts

Posted 10 May 2003 - 02:16 PM

In my computer science class we're learning a bit of this, but not enough for what I want to do. We won't learn what I want to do till next year. So I was wondering if anyone here knows how to go from one form to another by clicking a command button? If you do could you please tell me? I'm still trying to find it online too.
  • 0
Go Hokies!

#2 cxwq

cxwq

    Member

  • Founders
  • 3,634 posts

Posted 10 May 2003 - 03:48 PM

Fortunately, Visual Basic is not among the 8 or 10 languages I've programmed in but a quick glance around the web tells me that forms have a built in method called Show so you'd put something like this:

frmWhatever.Show

in the event handler for a button object.

Further grepping of the net tells me that VB has something awful called the "Command Button Wizard" that creates a button widget with some event handling code built in.
  • 0
<meta name="cxwq" content="mostly water">

#3 JT Nerf Girl

JT Nerf Girl

    Member

  • Members
  • 149 posts

Posted 12 May 2003 - 05:34 PM

Oh yeah, I'm good. Those didn't work, so I used what I *do* know about VBasic. You can make things visible and not visible right? That's all you do! The code for the command button is just

frmWhatever.Visible = False
frmWhatever2.Visible = True

It's as easy as that. Heh, aren't I smart?

Anyways, now I need to figure out how to make two of them random. Any ideas?

  • 0
Go Hokies!

#4 rawray7

rawray7

    Member

  • Members
  • 549 posts

Posted 12 May 2003 - 08:53 PM

well, i am doing VB in school right now. um...well to make something random here you go:

(lets say you have one main form, and 5 random forms)
in the main form make a command button called 'cmdrandom'. in the general section or the form load section of your code type: 'dim a'. in your form load type 'randomize'.

okay, that's all the preliminary stuff. now, in your cmdrandom code put:

a = int(5 * rnd + 1)
if a = 1 then
frm1.visible = true
frmmain.visible = false
end if
if a = 2 then
frm2.visible = true
frmmain.visible = false
end if
(and so on until 5)

the formula for creating a random integer between highnum and lownum is int(highnum * rnd + lownum)


i hope that helps. i would copy and paste code, but i would have to be at school to do that.
  • 0
You, nerfboi, are the suckest gun. -neonerfer

#5 cxwq

cxwq

    Member

  • Founders
  • 3,634 posts

Posted 12 May 2003 - 09:24 PM

Ray, I'm glad to see you working on your codewrangling skillz but why in the name of all that is holy are they teaching VB in our schools?!

MY TAXES ARE GOING TO MICROSOFT?!

It would be one thing to sell out to M$ and teach VC++, at least that's a useful skill but VB? The horror! The tragedy! The unstoppable urge to vomit!
  • 0
<meta name="cxwq" content="mostly water">

#6 rawray7

rawray7

    Member

  • Members
  • 549 posts

Posted 12 May 2003 - 10:52 PM

don't worry, you're tax dollars aren't being spent on my education. i go to a private school. and i don't know why we are learning VB. i think it's just as an introduction to coding in general, and Visual Basic is really...um....basic. in the more advanced computer classes they use Visual C++ primarily.
  • 0
You, nerfboi, are the suckest gun. -neonerfer


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users