Reputed number problem switch case statement

hai This is my code

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim i As String
i = TextBox1.Text
Dim x As Object
For Each x In i

Dim num As Integer
num = x.ToString()
Select Case num
Case 1
str1 = "R"
Case 2
str2 = "A"
Case 3
str3 = "V"
Case 4
str4 = "I"
Case 5
str5 = "N"
Case 6
str6 = "D"
Case 7
str7 = "R"
Case 8
str8 = "A"
Case 9
str9 = "N"
Case 0
str0 = "M"
case else
str11="O"

End Select


Next

Dim temp1, temp2 As String
temp1 = TextBox3.Text
temp2 = TextBox4.Text
TextBox2.Text = String.Concat(temp1, temp2, str1, str2, str3, str4, str5, str6, str7, str8, str9, str0,str11)


End Sub

i will enter 144 output RI it show me Last number leave it

my requirement is i will enter this kind of number check
last nearest number repeat at that time else case work
show string 'O' output like as RIO
send some idea about....

i need help from u all
by
srm.....

Recommended Answers

All 2 Replies

I think this is what you want:

Public Class Form1
    Dim i As String
    Dim x As Object
    Dim phrase As String
    Dim num As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        i = TextBox1.Text
        For Each x In i
            num = x.ToString()
            Select Case num
                Case 1
                    phrase += "R"
                Case 2
                    phrase += "A"
                Case 3
                    phrase += "V"
                Case 4
                    phrase += "I"
                Case 5
                    phrase += "N"
                Case 6
                    phrase += "D"
                Case 7
                    phrase += "R"
                Case 8
                    phrase += "A"
                Case 9
                    phrase += "N"
                Case 0
                    phrase += "M"
                Case Else
                    phrase += "O"
            End Select
        Next
        TextBox2.Text = phrase
    End Sub
End Class

To : Respected sir

Thank you very much sir for your quick and very useful reply. Finaly i have done my one problem.


This same solution if i will enter repeated number like as 222
first 2 i want display "A" if next strings come same 2's goto else part "o"

how i will to this some idea .......to me

Once again thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.