• We've upgraded our forums. Please post any issues/requests in this thread.

Visual Basic HELP

Joined
Feb 11, 2008
Messages
532 (0.15/day)
Likes
162
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#1
I use VB 2008 Express Edition, and I cannot get my multiple form application to work correctly. I am trying to get frmNext to show up after frmInput is done. So, in frmInput's button click event, I type in strName = TextBox1.Text, frmNext.Show(), and Unload frmInput. Unload does not work in vb 2008 anymore I guess, because it gave me an error. So, I typed in Me.Close(), which closes the application altogether. So, I decided to go into frmNext's form load event and type in Me.Text = strName and frmInput.Close(), which causes the entire program to close. I need help getting frmNext to show up and frmInput to close down.
 

ShadowFold

New Member
Joined
Dec 23, 2007
Messages
16,919 (4.64/day)
Likes
1,622
Location
Omaha, NE
System Name The ShadowFold Draconis (Ordering soon)
Processor AMD Phenom II X6 1055T 2.8ghz
Motherboard ASUS M4A87TD EVO AM3 AMD 870
Cooling Stock
Memory Kingston ValueRAM 4GB DDR3-1333
Video Card(s) XFX ATi Radeon HD 5850 1gb
Storage Western Digital 640gb
Display(s) Acer 21.5" 5ms Full HD 1920x1080P
Case Antec Nine-Hundred
Audio Device(s) Onboard + Creative "Fatal1ty" Headset
Power Supply Antec Earthwatts 650w
Software Windows 7 Home Premium 64bit
Benchmark Scores -❶-❸-❸-❼-
#2
Ah im not that great yet but could you post the whole code? I could probly help ive been using it for a few years now.
 
Joined
Feb 11, 2008
Messages
532 (0.15/day)
Likes
162
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#3
Option Explicit On
Module Module1
Public strName As String
End Module

Option Explicit On
Public Class frmInput

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
strName = TextBox1.Text
frmNext.Show()
Me.Close()

End Sub
End Class

Option Explicit On
Public Class frmNext

Private Sub frmNext_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = strName
End Sub
End Class
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#4
Create a module with a Sub "Main"
Code:
Imports System.Windows.Forms

Module Module1
  Sub Main()
    Dim frmInput as new FormInput
    frmInput.Show()
    Application.Run() // This starts the App without a start-up main form
  End Sub
End Module
In the Input Form (which will load as the default form)
Code:
Private closeApp as Boolean = True

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) handles Button1.Click
  closeApp = False;
  Dim nextFrm As New NextForm
  nextFrm.Show()
  Me.Close()
End Sub

// Just in case you want to kill the App from this form
Private Sub InputForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
   If closeApp Then
      Application.Exit()
   End If
End Sub
In Next Form, use something like this to close the Application
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Application.Exit()
End Sub
This is not the most robust way of doing this, but it should work for you.
 

Oliver_FF

New Member
Joined
Oct 15, 2006
Messages
544 (0.13/day)
Likes
65
Processor Intel q9400 @ stock
Motherboard Lanparty P45-T2RS
Cooling Zalman CNPS-9500
Memory 8GB OCZ PC2-6400
Video Card(s) BFG Nvidia GTX285 OC
Storage 1TB, 500GB, 500GB
Display(s) 20" Samsung T200HD
Case Antec Mini P180
Audio Device(s) Sound Blaster X-Fi Elite Pro
Power Supply 700w Hiper
Software Ubuntu x64 virtualising Vista
#5
Whenever I wanted to do something like that back in the day, i'd simply change the visibility of the form

frm.setVisible(true); to display it
frm.setVisible(false); to hide it
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#6
Whenever I wanted to do something like that back in the day, i'd simply change the visibility of the form

frm.setVisible(true); to display it
frm.setVisible(false); to hide it
That works okay, but then you have unneeded components and their associated resources hanging around eating up stack and heap space (RAM). It is better to dispose of the unneeded resource so that the garbage collector can clean up after you.
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#7
After some quick perusing ...

You may just be able to go into your projects properties page, and under the Application tab set the "Shutdown mode" to "After last form closes" instead of the default "When main form closes".