VB Questions
VB Questions
I'm new to making applications, and I need to know how to (in VB) make it so when you click your button, it opens a new form that you can add things to. Help is always appreciated, thanks.
Last edited by Patrickh on Sat Jun 30, 2007 10:21 pm, edited 1 time in total.
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
-
- Posts: 140
- Joined: Sat Jul 29, 2006 9:11 pm
- Location: Klein, TX
In VB 6 you go to project and then add form, then you put a command button and the code for it is (if you named the new form form2, if not replace form2 with what you named it.) In VB.net you go to project and then add windows form and put a command button and the code is
I hope that was helpful.
Code: Select all
form2.visible = true
Code: Select all
YourForm'sNameHere.show()
In another basic dialect, you can also add windows in code if you want to have multiple instances of a form. (Which might be useful for what you need to do.) It should work in VB.
First make and design a new form in your IDE like stephen10101 said. Then when you want to add that window during runtime do something like this:
First make and design a new form in your IDE like stephen10101 said. Then when you want to add that window during runtime do something like this:
Code: Select all
dim w as new custom_form
w.show
- LuxuriousMeat
- Posts: 824
- Joined: Thu Nov 03, 2005 6:43 pm
- Location: zzzzzzzzzzzzzzzz
- Contact:
o ok yeah then all u do is type
Code: Select all
form2(or what ever its name is).show()
(An Old one.)
Wow! Thank you guys so much. I can do all sorts of things I was just really tired of jamming them all into one form. Now the possibilities are endless!
Thanks again.
Thanks again.
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
yeah, the reason I'm doing VB is because I started off using Locke's tutorials.
I have another problem, I'm not sure why this doesn't work.
My main form is called frmExplorer2. Then I have another form (form4) that contains a textbox (TextBox1) and a button (cmdname)
I tried to make it so that if you type some thing in the box, then hit the button, it sets the title of the main form to whatever's in the box. It worked when I put the box and button in the main form, but not when they are in the new window (it just does nothing). Anyway, here's what I wrote:
no build errors, but it doesn't work...
I have another problem, I'm not sure why this doesn't work.
My main form is called frmExplorer2. Then I have another form (form4) that contains a textbox (TextBox1) and a button (cmdname)
I tried to make it so that if you type some thing in the box, then hit the button, it sets the title of the main form to whatever's in the box. It worked when I put the box and button in the main form, but not when they are in the new window (it just does nothing). Anyway, here's what I wrote:
Code: Select all
Public Class Form4
Private Sub cmdname_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
frmExplorer2.Text = "" & TextBox1.Text
End Sub
End Class
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
because you wrote frmexplorer2 and not form2 or in your case form4
it should be like this
and the reason u have a exploer is beacause you picked explorer instead of windows form
Code: Select all
Public Class Form4
Private Sub cmdname_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
frmExplorer2.Text = "" & TextBox1.Text
End Sub
End Class
Code: Select all
Public Class Form4
Private Sub cmdname_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
form4.Text = "" & TextBox1.Text
End Sub
End Class
(An Old one.)
You misunderstand what the problem is. And I can't figure out why that wouldn't work. You might need to refresh the form to make the change visible.Patrickh wrote:My main form is called frmExplorer2. Then I have another form (form4) that contains a textbox (TextBox1) and a button (cmdname)
I tried to make it so that if you type some thing in the box (in form4), then hit the button (also in form4), it sets the title of the main form (frmExplorer2) to whatever's in the box...
Code: Select all
Public Class Form4
Private Sub cmdname_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
frmExplorer2.Text = "" & TextBox1.Text
frmExplorer2.Refresh
End Sub
End Class
Okay, I erased it all and typed it out again and it worked. Dagger, yours works for changing the name of form4, except you have to change form4 in the third line to 'Me'.
I was trying to change the name of a different form via this form. Here's what it looks like:
I was trying to change the name of a different form via this form. Here's what it looks like:
Code: Select all
Public Class Form4
Private Sub cmdname_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdname.Click
frmExplorer2.Text = "" & TextBox1.Text
End Sub
End Class
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
Code: Select all
Public Class Form4
Private Sub cmdname_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
frmExplorer2.Text = "" & TextBox1.Text
frmExplorer2.Refresh
End Sub
End Class
and make sure you have the form that u want to change the name is open
(An Old one.)
Would anybody mind if I just renamed this topic to 'VB questions' and just posted any problems/questions here rather than flooding the section with new topics?
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
Ok, new problem. I made a program that opens .txts, edits them and then can save them somewhere. So I decided to make another one but for images. I got it so that when you hit File>Open it opens a Open Folder Dialogue, you browse for an image, hit open, and the image appears in a picbox, with the location in a textbox. no issues so far. However, I can't get it to save . I've tried several methods with no luck. I need the code so that when you hit a button, lets say 'cmdSave', a Save File Dialog opens, and you can save your image (as a JPEG, I can figure out the rest). Call the Box whatever, I can always edit it, but I need a working code to study for future use. Thanks a lot to whoever helps me.
EDIT: Actually if you can only save as bmp that's fine too. And keep in mind I started programming like 2 or 3 days ago.
EDIT: Actually if you can only save as bmp that's fine too. And keep in mind I started programming like 2 or 3 days ago.
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
Jw why you concant empty string and TextBox1.Text, you can just put TextBox1.Text, and if you're trying to add what's in TextBox1 to the end of frmExplorer2.Text you should put &= i think(I forgot most of what I learned in VB.net). That's where I started out too, but I like C# better.Dagger13 wrote:no u dont have to refresh it and yes i forgot u do have to put "me.show"Code: Select all
Public Class Form4 Private Sub cmdname_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) [b]frmExplorer2.Text = "" & TextBox1.Text [/b] frmExplorer2.Refresh End Sub End Class
and make sure you have the form that u want to change the name is open
Heres the C# for saving the image of a picturebox, should only be marginally different in VB
Code: Select all
//let p be the picturebox
p.Image.Save("filename", System.Drawing.Imaging.ImageFormat.Bmp);
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
Halo 3 Research Thread - Contribute to the research into Halo 3.
I think it's much different in VB, I'll tinker with that though.
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
- LuxuriousMeat
- Posts: 824
- Joined: Thu Nov 03, 2005 6:43 pm
- Location: zzzzzzzzzzzzzzzz
- Contact:
Nope its the exact same way...Patrickh wrote:I think it's much different in VB, I'll tinker with that though.
Code: Select all
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image.Save("filename", System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
End Class