the_carpenter 21 Junior Poster in Training

You could always save each field by using

SaveSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", textbox1.txt) 
' Do a version of the line above for each field you want to save

Then when you reload the form put the following in the load event

Textbox1.text = GetSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", "(default)")
the_carpenter 21 Junior Poster in Training

not one line of code... but a subroutine to do all textboxes. And you can make it global so it can be called from Any Form.

Add a new code module to your project. Add the following code to the module:

Public Sub SetTextBoxAlignment(ByRef TargetForm As Form, ByVal tbAlignment As Windows.Forms.HorizontalAlignment, Optional ByRef WatchForExceptions As Boolean = False)

        For Each ctlOnForm As Control In TargetForm.Controls
            If TypeOf ctlOnForm Is TextBox Then
                Dim tmpTB As TextBox = DirectCast(ctlOnForm, TextBox)


                If String.IsNullOrEmpty(tmpTB.Tag) Then
                    tmpTB.TextAlign = tbAlignment

                Else
                    If WatchForExceptions Then
                        If Not tmpTB.Tag.ToString.StartsWith("x") Then
                            tmpTB.TextAlign = tbAlignment

                        End If
                    Else
                        tmpTB.TextAlign = tbAlignment
                    End If

                End If
            End If
        Next
    End Sub

How to use the above Subroutine:

This will set the textbox alignment for the current form to center:

SetTextBoxAlignment(Me, HorizontalAlignment.Center)

If you want to set the alignment for most of the textboxes but one or two, place an "x" in the Tag properties of those textboxes you which to exclude. Then use this line to set the alignment for all the textboxes except the ones you "Tagged".

SetTextBoxAlignment(Me, HorizontalAlignment.Center, True)
the_carpenter 21 Junior Poster in Training

Please tell me you're not using in-line coded connection strings.

1: Hopefully you're using a connection string that isn't hard coded and/or in-line with your code.

A. If it is, you need someway to manage and alter that connection string via your application (have an options form or administration form)

B. If it isn't and you've made it part of settings you should have a .config file that has the same name as your exe. For example, if your application file name is WonderApp.exe then there should be a file called WonderApp.exe.config. You can carefully edit this file with notepad and change the connection string.

2. Hopefully you've been testing your application on a different computer from your development machine. You need to have a computer that doesn't have all the applications and development tools that your computer has installed. This second computer should be your QC (Quality Control) machine and it should be kept as clean as possible. (No extra applications... don't use it for a gaming machine)

When you install your app on the QC machine, you will see what you're missing from your setup package and how well your app really works in the real world. Without this machine you're just guessing your application will work. Without QC you will look bad every time one of your users discovers an error in your app.

kvprajapati commented: Good explanation!!! +10
the_carpenter 21 Junior Poster in Training

Try setting the doublebuffered property of the form to true.

kvprajapati commented: Ofcourse +10
the_carpenter 21 Junior Poster in Training

the four text boxes (tA, tB, tC, tD)

one button (cmdCalculate)

and one more text box with a name that doesn't start with "t" (OutputTxtAvg)

Private Sub cmdCalculate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click

        Dim iNumeratorCnt As Integer = 0
        Dim iSum As Integer = 0

        For Each ctrl As Control In Me.Controls
            If ctrl.Name.StartsWith("t") Then
                Dim tmpText As New TextBox
                tmpText = DirectCast(ctrl, TextBox)
                If tmpText.Text.Length > 0 Then
                    Try
                        iSum += Val(tmpText.Text)
                        iNumeratorCnt += 1


                    Catch ex As Exception
                        MessageBox.Show("Please enter valid integers", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                End If

            End If
        Next
        If iNumeratorCnt > 0 Then
            OutputtxtAvg.Text = Convert.ToDouble(iSum / iNumeratorCnt)
        End If

    End Sub
the_carpenter 21 Junior Poster in Training

So there are a couple of ways to validate the format of an email address.

You could always to the simple look for the @ sign and make sure there is a dot (.) somewhere after the @ sign.

Or the kind of cool and groovy method of using Regular Expressions (RegEx).

Here's how you do it:
Add a textbox (Textbox1) and a button (Button1) to a form.

Switch to code view.

Add the imports statement

Imports System.Text.RegularExpressions

Then in your Button1_Click Event add the following code:

Dim strMessage As String = ""
        Dim regex As Regex = New Regex("([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\." + _
                                       ")|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})", _
                                       RegexOptions.IgnoreCase _
                                       Or RegexOptions.CultureInvariant _
                                       Or RegexOptions.IgnorePatternWhitespace _
                                       Or RegexOptions.Compiled _
                                       )
        Dim IsMatch As Boolean = regex.IsMatch(TextBox1.Text)
        If IsMatch Then
            If TextBox1.Text.Equals(regex.Match(TextBox1.Text).ToString) Then
                strMessage = "Valid email address"
            Else
                strMessage = "There's an email address in there somewhere.  But not exactly"
            End If
        Else
            strMessage = "Sorry.  Invalid email address format."
        End If
        MessageBox.Show(strMessage)

By the way there is no good way to tell if an address actually exists (or is valid) until you get a response back from the server telling you it doesn't exists. Unless of course you're the system administrator of that particular email server.

the_carpenter 21 Junior Poster in Training

What doing the conversion? Visual Studio?

Try Artinsoft Visual Basic Upgrade Companion.

They have a free 1 month/ 10,000 lines of code limit. But it could get you further along.

Simran Kaur commented: was helpful +1
the_carpenter 21 Junior Poster in Training

Since the listbox implements IList, make a class that implements IList and connected to the listbox's datasource.

For example:
Here is your basic class

Public Class clsFunctionInfo

    Private _idxFunction As Integer

    Public Property IdxFunction() As Integer
        Get
            Return _idxFunction
        End Get
        Set(ByVal value As Integer)
            _idxFunction = value
        End Set
    End Property
    Private _strFunction As String

    Public Property StrFunction() As String
        Get
            Return _strFunction
        End Get
        Set(ByVal value As String)
            _strFunction = value
        End Set
    End Property

    Private _iFunctionNumber As Integer
    Public Property IFunctionNumber() As Integer
        Get
            Return _iFunctionNumber
        End Get
        Set(ByVal value As Integer)
            _iFunctionNumber = value
        End Set
    End Property

End Class

Then you make a class to manage your collection of the above classes

Imports Microsoft.VisualBasic.FileIO

Public Class clsFunctionXref
    Implements System.Collections.IList

    Private _colFunctionInfo As New Collection

    Private _filePath As String
    Public Property FilePath() As String
        Get
            Return _filePath
        End Get
        Set(ByVal value As String)
            _filePath = value
        End Set
    End Property



    Public Sub New(ByVal filename As String)
        _filePath = filename

        Dim _idx As Integer = 1
        Dim fields As String()
        Dim delimiter As String = ","
        Dim iFnx As Integer
        Using parser As New TextFieldParser(filename)
            parser.SetDelimiters(delimiter)
            While Not parser.EndOfData
                ' Read in the fields for the current line
                fields = parser.ReadFields()

                Try
                    iFnx = Convert.ToInt16(fields(0).ToString)
                Catch ex As Exception
                    MessageBox.Show("Error reading file.  " & ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    Exit Sub
                End Try

                Dim objFunction As New clsFunctionInfo
                objFunction.IdxFunction = _idx
                objFunction.IFunctionNumber = iFnx
                objFunction.StrFunction = fields(1).ToString
                Me.Add(objFunction)
                _idx += 1

            End While
        End …