Listing 1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
 Handles Button1.Click
' Note: code is not provided in a separate class library to
'       minimize example length

        Dim Sequence As String
        Dim MW As Double
        Dim I As Integer
        Dim S As String
        MW = 0
        Sequence = RichTextBox1.Text

        'Reads each character (amino acid) in the string and
        'adds the appropriate weight in Daltons
        For I = 1 To Len(Sequence)
            S = Mid(Sequence, I, 1)
            Select Case S
                Case "G"
                    MW = MW + 57
                Case "A"
                    MW = MW + 71.1
                Case "V"
                    MW = MW + 99.1
                Case "L"
                    MW = MW + 113.2
                Case "I"
                    MW = MW + 113.2
                Case "M"
                    MW = MW + 131.2
                Case "P"
                    MW = MW + 97.1
                Case "F"
                    MW = MW + 147.2
                Case "W"
                    MW = MW + 186.2
                Case "S"
                    MW = MW + 87.1
                Case "T"
                    MW = MW + 101.1
                Case "N"
                    MW = MW + 114.1
                Case "Q"
                    MW = MW + 128.1
                Case "Y"
                    MW = MW + 163.2
                Case "C"
                    MW = MW + 103.1
                Case "K"
                    MW = MW + 128.2
                Case "R"
                    MW = MW + 156.2
                Case "H"
                    MW = MW + 137.1
                Case "D"
                    MW = MW + 115.1
                Case "E"
                    MW = MW + 129.1
                Case Else
                    MsgBox("Not a valid entry!")
            End Select
        Next
        MW = MW + 18
        'Converts from Daltons to KiloDaltons
        MW = MW / 1000
        If MW <> 0.018 Then
            TextBox1.Text = "The Molecular Weight of the protein is " & MW & "
			 KiloDaltons."
        Else
            TextBox1.Text = "Please Enter a Sequence"
        End If
End Sub