Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   First-time setup of application (http://www.programmingforums.org/showthread.php?t=15486)

Jabo Mar 26th, 2008 10:40 AM

First-time setup of application
 
I want to have my program check to see if certain information has been setup up, like server address, etc. I want the application to check and if this information hasn't been setup, then it will prompt the user to enter this information for first-time setup. I tried putting this in the first form load event, but it doesn't do what I want. Can somebody point me in the right direction?

Infinite Recursion Mar 27th, 2008 8:05 AM

Re: First-time setup of application
 
How about in the Form_Load, you check for values in the registry that indicate if the information has previously been provided?

Jabo Mar 27th, 2008 7:46 PM

Re: First-time setup of application
 
I'm not that sophisticated yet Recursion; my information is held in .txt files. I tried putting my check in the main form load event, but it ignores it. I'd like to do my checks before the main form loads, but don't know how.

Ooble Mar 27th, 2008 8:51 PM

Re: First-time setup of application
 
Show us some code, Jabo.

Jabo Mar 27th, 2008 10:56 PM

Re: First-time setup of application
 
The code that I tried is the first IF statement. I realize that the form hasn't loaded yet and can't be hid, but why wouldn't it show my other form? How can I do this better?

Also, frommail is a string that has been assigned a filepath. It was declared publicly.

:

  1. Private Sub Pinger_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.  
  3.         Dim tabs() As Integer = {20, 40, 60, 80}
  4.  
  5.         If IO.File.Exists(frommail) = False Then
  6.             Me.Hide()
  7.             frmFromEmail.Show()
  8.         End If
  9.  
  10.         'Set result textbox to nothing on load
  11.         rtbResult.Text = ""
  12.         'Ensure timer is enabled
  13.         tmrTimer.Enabled = True
  14.         'Set toolstrip Status message
  15.         tssStatus.Text = "Pinging Started"
  16.         'Set toolstrip Activity to None
  17.         tssActivity.Text = "Current Task: None"
  18.         'Cause both toolstrips to redraw
  19.         tssStatus.Invalidate()
  20.         tssActivity.Invalidate()
  21.         'set Result textbox tabs
  22.         rtbResult.SelectionTabs = tabs
  23.         'Enable Stop toolstrip and disable Start toolstrip
  24.         StopToolStripMenuItem.Enabled = True
  25.         StartToolStripMenuItem.Enabled = False
  26.         'Set timer interval to 15 minutes
  27.         interval = 900000
  28.         tmrTimer.Interval = interval
  29.         'Make email active menu checked
  30.         EmailActiveToolStripMenuItem.Checked = True
  31.         'Set 15 minute menu to checked, all others unchecked
  32.         MinutesToolStripMenuItem.Checked = False
  33.         MinutesToolStripMenuItem1.Checked = False
  34.         MinutesToolStripMenuItem2.Checked = True
  35.         MinutesToolStripMenuItem3.Checked = False
  36.         MinutesToolStripMenuItem4.Checked = False
  37.         'Set printing to inactive
  38.         PrintingActiveToolStripMenuItem.Checked = False
  39.         'Set interval label to 15 minutes
  40.         lblInterval.Text = "Ping interval: " & tmrTimer.Interval.ToString / 60000 & " minutes"
  41.         'Start timer and cause first ping to run
  42.         tmrTimer.Start()
  43.         Ping_list()
  44.  
  45.  
  46.     End Sub


Jabo Mar 28th, 2008 12:10 AM

Re: First-time setup of application
 
Basically, this program needs an email server to send to, a From: email address and some other text files with specific information that the program needs to work properly. I don't want the program to crash on somebody on first use, which it has been doing until those files are created. After the files are there, program works fine. I guess what I'm looking for is the VB equivalent of preprocessor directives such as #ifdef and #ifndef.

I had all that information hard-coded into the program for work use, but they changed our domain on our emails, which meant I had to go back and change the information then recompile. I want my program more robust than that so I'm removing the key elements being hard-coded into the program.

Ooble Mar 28th, 2008 11:59 AM

Re: First-time setup of application
 
Seems the problem is with this line:
:

  1. frmFromEmail.Show()

Try this. Can't guarantee anything as I'm not a VB coder, but hopefully it'll work.
:

  1. Private Sub Pinger_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Dim tabs() As Integer = {20, 40, 60, 80}
  3.         Dim FromEmailForm As New frmFromEmail()
  4.  
  5.         If IO.File.Exists(frommail) = False Then
  6.             Me.Hide()
  7.             FromEmailForm.Show()
  8.         End If


Jabo Mar 28th, 2008 7:57 PM

Re: First-time setup of application
 
I'll give it a try, thanks for the suggest Ooble


All times are GMT -5. The time now is 1:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC