• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

quick vb question (1 Viewer)

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
ok i kinda suck at vb

heres a quick question

umm

say i have the main form (form1)
how do i make it so that another form (say form2) is open and active when form1loads

when i do:

Private Sub Form_Load()
Load Form2
Form2.Show
End Sub

it opens alrite except wot i want to do is make it active and also so u cant switch windows back to form1 once form2 is opened when the program starts up
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
This is called making Form2 modal

Code:
Private Sub Form_Load()
    ' this is needed to make sure form1 shows up
    Form1.Show
    ' make form2 show and modal, making form1 the owner of form2
    Form2.Show vbModal, Form1
End Sub
 

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
hmm one more quick question

say i have 10 different pictures
eg : c:\images\pic1.gif etc... named pic1 to pic 10

say i have a image tool and the command button drawn already

i want to make the image change from image 1 to 10 everytime i click the command button
(i.e: if its showing image1, when i click on the button i want it to change to image 2, if its showing image 2 i want it to show image 3 and so on)

sorri abt this im new to vb :)
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
Try and piece these together yourself. Say you have three pictures, pic1, pic2, and pic3 and you start your program with pic1 loaded into the imagebox control. At the same time keep track of which picture you have loaded with a variable that holds the number (1,2 or 3).

Then each time you click the button, increment the number, check if its over ten (if it is then set the number back to 1) and then load the picture called "pic" & variable & ".bmp" into the imagebox.
 

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
thanks sunny i got it to work now

before i was tryin to store the variables with the filename location... didnt quite work out haha
 

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
hmm how do i make it so i can make the link to the images 1-10 which are in a folder 1 level up (from the project location) called "images"

heres my code so far
If i > 1 Then
Image4.Picture = LoadPicture("c:\images\" & i & ".gif")
i = i - 1
without typing the whole filename (eg : c:\images\pic1.gif)
all i want to do is link it to the folder up one level from where the program is located

coz i know if i run the program on a different computer the pictures obviously wont show up because there wont be a folder called "c:\images" on their computer
 
Last edited:

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
You can use App.Path to return the current path that the VB executable is in. So if your program was in c:\images, App.Path will return a string that says "C:\images"
 

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
thx (3rd time)
works like a beauty hehe :)

sorry if ive been buggin ya with these easy silly questions
 

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
your first question sound very like a implementation of a splash screen
 

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
well kinda not really
more of a "setup" screen for a game im making
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top