Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How can I output the correct value from a string?

$
0
0
So I am trying to get the correct values from this string, however some of the input varies so where F8L0000 is equal to (0)= Factory (1) = 2008 (3) = December. However I now also have the issue where some numbers are longer on the year so F13L000 Should be Factory, 2013, December. I can only get Factory, 2001, NA. I am really lost on this. what can I do to get this working correctly again?

 Private Sub SubmitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubmitButton.Click

        Dim strType As String = Field1.Text(0)
        Dim strYear As String = Field1.Text(2)
        Dim strMonth As String = Field1.Text(1)
        Dim strMonth0 As String = Field1.Text(3)
        Dim iFalse As String = ("If N/A then your data may be incorrect")

        Select Case Field1.Text(0)
            Case "F", "f"
                strType = "Factory Produced in:"
            Case Else
                strType = "Other Produced in:"

        End Select


        Select Case Field1.Text(2)
            Case "A", "a"
                strMonth = "Jan"
            Case "B", "b"
                strMonth = "Feb"
            Case "C", "c"
                strMonth = "Mar"
            Case "D", "d"
                strMonth = "Apr"
            Case "E", "e"
                strMonth = "May"
            Case "F", "f"
                strMonth = "Jun"
            Case "G", "g"
                strMonth = "Jul"
            Case "H", "h"
                strMonth = "Aug"
            Case "I", "i"
                strMonth = "Sep"
            Case "J", "j"
                strMonth = "Oct"
            Case "K", "k"
                strMonth = "Nov"
            Case "L", "l"
                strMonth = "Dec"
            Case "0"
                strYear = "2010"
            Case "1"
                strYear = "2011"
            Case "2"
                strYear = "2012"
            Case "3"
                strYear = "2013"
            Case Else
                strMonth = "N/A"

        End Select


        Select Case Field1.Text(1)
            Case "0"
                strYear = "2000 OR 2010"
            Case "1" Or Field1(2) = "2013"

                strYear = "2001"
            Case "2"
                strYear = "2002 OR 2012"
            Case "3"
                strYear = "2003 OR 2013"
            Case "4"
                strYear = "2004"
            Case "5"
                strYear = "2005"
            Case "6"
                strYear = "2006"
            Case "7"
                strYear = "2007"
            Case "8"
                strYear = "2008"
            Case "9"
                strYear = "2009"
            Case Else
                strYear = "N/A"

        End Select

        Select Case Field1.Text(3)
            Case "A", "a"
                strMonth = "Jan"
            Case "B", "b"
                strMonth = "Feb"
            Case "C", "c"
                strMonth = "Mar"
            Case "D", "d"
                strMonth = "Apr"
            Case "E", "e"
                strMonth = "May"
            Case "F", "f"
                strMonth = "Jun"
            Case "G", "g"
                strMonth = "Jul"
            Case "H", "h"
                strMonth = "Aug"
            Case "I", "i"
                strMonth = "Sep"
            Case "J", "j"
                strMonth = "Oct"
            Case "K", "k"
                strMonth = "Nov"
            Case "L", "l"
                strMonth = "Dec"
        End Select

        My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Exclamation)
        MessageBox.Show(String.Format("{0} {1} {2}", strType, strMonth, strYear))
        If strYear = "N/A" Then
            MessageBox.Show(iFalse)
        ElseIf strMonth = "N/A" Then
            MessageBox.Show(iFalse)
        End If


        'F8L0038 = Factory 2008 December'

    End Sub


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>