I just have an assignment that tells me to do the following things.

Create a button. When that button is clicked, an InputBox will appear to let the user enter a word or phrase.

Then, there are 2 radio buttons: Encode & Decode

When Encode is checked "True", the label should display the "binary integer for each letter in the InputBox, including the space.

When Decode is checked "True", the label should convert the "binary integer" back into the original word or phrase that the user first enters.

Here's my code so far, and it does work:

Public Class Form1
    Public strstore As String

    Private Sub btnenter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnenter.Click
        Dim strenter As String
        strenter = InputBox("Enter a word or phrase:")
        strstore = strenter
    End Sub

    Private Sub radencode_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles radencode.Click
        If radencode.Checked = True Then
            Dim Letters = From c As Char In strstore.ToCharArray Select AscW(c) & " "
            Me.lblanswer.Text = String.Join("", Letters.ToArray)
        End If
    End Sub

    Private Sub raddecode_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles raddecode.Click
        If raddecode.Checked = True Then
            Me.lblanswer.Text = strstore
        End If
    End Sub
End Class

But then, part B of the assignment says: Create another button. When the button is clicked, 2 will be added to every "binary integer", except for the space, whose binary code is "32". After that, convert those series of "updated binary integer" back into a word or phrase.

How can I do this?

Take a look at this example.

Sub Main()

        Dim mystring As String = "This is a string"
        Dim chars As Char() = mystring.ToCharArray()

        For i As Integer = 0 To chars.Length - 1
            Dim c As Char = chars(i)
            If (AscW(c) <> 32) Then
                c = ChrW(AscW(c) + 2)
                chars(i) = c
            End If
        Next

        Dim newstring As String = New String(chars)
        Console.WriteLine(newstring)

        Console.Read()

    End Sub

If anything, you'll have great experience with arrays of Char by the end of all these problems!

take a look at this complete example
it still need some job from you
(tiny job, if you figure it out then you understood a big part of my code, that way you get the benefits of the assignment, which is understanding the code)

Private Sub btn_Encode_Click() Handles btn_Encode.Click
    Dim Letters = From c As Char In Label1.Text.ToCharArray _
                     Select AscW(c) & " "
    Me.Label1.Text = (String.Join("", Letters.ToArray)).Trim
End Sub

Private Sub btn_Input_Click() Handles btn_Input.Click
    Label1.Text = InputBox("")
End Sub

Private Sub btn_Decode_Click() Handles btn_Decode.Click

    Dim Integers() = Label1.Text.Split(" ")
    Dim fun = Function(s As String) _
                  Convert.ToChar(Integer.Parse(s))

    Dim NewStringChars = From I As String In Integers _
                         Select (fun(I).ToString)

    Me.Label1.Text = String.Join("", NewStringChars.ToArray)
End Sub

hope this helps

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.