"Coder" Program

I can't figure out why this program won't run

Page 1 of 1

10 Replies - 1186 Views - Last Post: 21 December 2008 - 11:39 AM Rate Topic: -----

#1 coder001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 15-December 08

"Coder" Program

Post icon  Posted 19 December 2008 - 03:05 PM

I'm working on a program called Coder. Before you read the code, here are the instructions for the program: " Create a Coder application that encodes and decodes a message using Unicode.
BTY: You advance programmers should already be aware of Unicode

 Public Class Form1
	Dim strMessage As String
	Dim strCodedMessage As String

	Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
		If radEncode.Checked = True Then
			strMessage = txtInput.Text

			If strMessage = Nothing Then
				MsgBox("Please enter a message to decode")
			Else
				For intNum As Integer = 0 To (strMessage.Length - 1)
					If strMessage.Chars(intNum) = "Y" Then
						strCodedMessage = strCodedMessage & "A" & " "
					ElseIf strMessage.Chars(intNum) = "Z" Then
						strCodedMessage = strCodedMessage & "B" 7 " "
					Else
						strCodedMessage = strCodedMessage & ChrW(AscW(strMessage.Chars(intNum)) + 2)
					End If
				Next
			End If
		End If
		txtInput.Text = strCodedMessage

		strMessage = Nothing
		strCodedMessage = Nothing
		ElseIf radDecode.Checked = True Then
		strCodedMessage = txtInput.Text

		strCodedMessage.Trim(" ")
		strCodedMessage = strCodedMessage.PadRight(strCodedMessage.Length + 1)

		Dim intMax As Integer = strCodedMessage.Length - 1

		For intNum As Integer = 0 To intMax
			If strCodedMessage = "" Then

				If strCodedMessage.Chars(intNum) = "A" Then
					strMessage = strMessage & "Y"
					strCodedMessage = strCodedMessage.Remove(0, intNum + 1)
				ElseIf strCodedMessage.Chars(intNum) = "B" Then
					strMessage = strMessage & "Z"
					strCodedMessage = strCodedMessage.Remove(0, (intNum + 1))
				Else
					Dim strVar As String

					For intNum2 As Integer = 0 To (intNum)
						strVar = strVar & AscW(strCodedMessage.Chars(intNum2))
					Next
					Dim intVar = Val(strVar) - 2

					strMessage = strMessage & ChrW(intVar)

					strCodedMessage = strCodedMessage.Remove(0, 1)
					strVar = Nothing
				End If
				intNum = -1
				intMax = strCodedMessage.Length - 1
			End If
		Next

		txtInput.Text = strMessage

		strMessage = Nothing
		strCodedMessage = Nothing
	End Sub

	Private Sub EncodeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EncodeToolStripMenuItem.Click
		radEncode.Enabled = True
	End Sub

	Private Sub DecodeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DecodeToolStripMenuItem.Click
		radDecode.Enabled = True
	End Sub

	Private Sub txtInput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInput.TextChanged
		Static blnClicked As Boolean = False
		If blnClicked = False Then
			With txtInput
				.Text = ""
				.TextAlign = HorizontalAlignment.Left
			End With
		End If
	End Sub

	Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
		Close()
	End Sub
End Class



Is This A Good Question/Topic? 0
  • +

Replies To: "Coder" Program

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: "Coder" Program

Posted 19 December 2008 - 03:20 PM

You say it wont run, do you get an error? If so what is the exact error message?
Was This Post Helpful? 0
  • +
  • -

#3 coder001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 15-December 08

Re: "Coder" Program

Posted 19 December 2008 - 05:01 PM

View Postcoder001, on 19 Dec, 2008 - 02:05 PM, said:

I'm working on a program called Coder. Before you read the code, here are the instructions for the program: " Create a Coder application that encodes and decodes a message using Unicode.
BTY: You advance programmers should already be aware of Unicode

 Public Class Form1
	Dim strMessage As String
	Dim strCodedMessage As String

	Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
		If radEncode.Checked = True Then
			strMessage = txtInput.Text

			If strMessage = Nothing Then
				MsgBox("Please enter a message to decode")
			Else
				For intNum As Integer = 0 To (strMessage.Length - 1)
					If strMessage.Chars(intNum) = "Y" Then
						strCodedMessage = strCodedMessage & "A" & " "
					ElseIf strMessage.Chars(intNum) = "Z" Then
						strCodedMessage = strCodedMessage & "B" 7 " "
					Else
						strCodedMessage = strCodedMessage & ChrW(AscW(strMessage.Chars(intNum)) + 2)
					End If
				Next
			End If
		End If
		txtInput.Text = strCodedMessage

		strMessage = Nothing
		strCodedMessage = Nothing
		ElseIf radDecode.Checked = True Then
		strCodedMessage = txtInput.Text

		strCodedMessage.Trim(" ")
		strCodedMessage = strCodedMessage.PadRight(strCodedMessage.Length + 1)

		Dim intMax As Integer = strCodedMessage.Length - 1

		For intNum As Integer = 0 To intMax
			If strCodedMessage = "" Then

				If strCodedMessage.Chars(intNum) = "A" Then
					strMessage = strMessage & "Y"
					strCodedMessage = strCodedMessage.Remove(0, intNum + 1)
				ElseIf strCodedMessage.Chars(intNum) = "B" Then
					strMessage = strMessage & "Z"
					strCodedMessage = strCodedMessage.Remove(0, (intNum + 1))
				Else
					Dim strVar As String

					For intNum2 As Integer = 0 To (intNum)
						strVar = strVar & AscW(strCodedMessage.Chars(intNum2))
					Next
					Dim intVar = Val(strVar) - 2

					strMessage = strMessage & ChrW(intVar)

					strCodedMessage = strCodedMessage.Remove(0, 1)
					strVar = Nothing
				End If
				intNum = -1
				intMax = strCodedMessage.Length - 1
			End If
		Next

		txtInput.Text = strMessage

		strMessage = Nothing
		strCodedMessage = Nothing
	End Sub

	Private Sub EncodeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EncodeToolStripMenuItem.Click
		radEncode.Enabled = True
	End Sub

	Private Sub DecodeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DecodeToolStripMenuItem.Click
		radDecode.Enabled = True
	End Sub

	Private Sub txtInput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInput.TextChanged
		Static blnClicked As Boolean = False
		If blnClicked = False Then
			With txtInput
				.Text = ""
				.TextAlign = HorizontalAlignment.Left
			End With
		End If
	End Sub

	Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
		Close()
	End Sub
End Class




It won't run and there are 2 erros.
Error #1 says: "End of statement expected". It is this line right here
ElseIf strMessage.Chars(intNum) = "Z" Then 
						strCodedMessage = strCodedMessage & "B" 7 " "
It's those quotation marks (line 16, columm 65)
Error #2 says: ElseIf must be preceded by a matching "If" or ElseIf". It is this line right here
 ElseIf radDecode.Checked = True Then
(line 27, column 9)
Was This Post Helpful? 0
  • +
  • -

#4 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: "Coder" Program

Posted 19 December 2008 - 05:18 PM

Looks liek you type a '7' instead of a '&' to concat the strings...

strCodedMessage = strCodedMessage & "B" & " " 'You need to replace that 7 with an &


Was This Post Helpful? 0
  • +
  • -

#5 coder001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 15-December 08

Re: "Coder" Program

Posted 19 December 2008 - 07:30 PM

View Postmagicmonkey, on 19 Dec, 2008 - 04:18 PM, said:

Looks liek you type a '7' instead of a '&' to concat the strings...

strCodedMessage = strCodedMessage & "B" & " " 'You need to replace that 7 with an &



Oh yeah, thanks. Now I fixed the "ElseIf" error but now I can't type anything in the textbox. Do you know why?
Was This Post Helpful? 0
  • +
  • -

#6 coder001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 15-December 08

Re: "Coder" Program

Posted 20 December 2008 - 05:27 PM

Could someone tell me why my program won't work and how to fix it?

 Public Class Form1
	Dim strMessage As String
	Dim strCodedMessage As String

	Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
		If radEncode.Checked = True Then
			strMessage = txtInput.Text

			If strMessage = Nothing Then
				MsgBox("Please enter a message to decode")
			Else
				For intNum As Integer = 0 To (strMessage.Length - 1)
					If strMessage.Chars(intNum) = "Y" Then
						strCodedMessage = strCodedMessage & "A" & " "
					ElseIf strMessage.Chars(intNum) = "Z" Then
						strCodedMessage = strCodedMessage & "B" & " "
					Else
						strCodedMessage = strCodedMessage & ChrW(AscW(strMessage.Chars(intNum)) + 2)
					End If
				Next
			End If
		End If
		txtInput.Text = strCodedMessage

		If strMessage = Nothing Then
			strCodedMessage = Nothing
		ElseIf radDecode.Checked = True Then

		End If
		strCodedMessage = txtInput.Text

		strCodedMessage.Trim(" ")
		strCodedMessage = strCodedMessage.PadRight(strCodedMessage.Length + 1)

		Dim intMax As Integer = strCodedMessage.Length - 1

		For intNum As Integer = 0 To intMax
			If strCodedMessage = "" Then

				If strCodedMessage.Chars(intNum) = "A" Then
					strMessage = strMessage & "Y"
					strCodedMessage = strCodedMessage.Remove(0, intNum + 1)
				ElseIf strCodedMessage.Chars(intNum) = "B" Then
					strMessage = strMessage & "Z"
					strCodedMessage = strCodedMessage.Remove(0, (intNum + 1))
				Else
					Dim strVar As String

					For intNum2 As Integer = 0 To (intNum)
						strVar = strVar & AscW(strCodedMessage.Chars(intNum2))
					Next
					Dim intVar = Val(strVar) - 2

					strMessage = strMessage & ChrW(intVar)

					strCodedMessage = strCodedMessage.Remove(0, 1)
					strVar = Nothing
				End If
				intNum = -1
				intMax = strCodedMessage.Length - 1
			End If
		Next

		txtInput.Text = strMessage

		strMessage = Nothing
		strCodedMessage = Nothing
	End Sub

	Private Sub EncodeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EncodeToolStripMenuItem.Click
		radEncode.Enabled = True
	End Sub

	Private Sub DecodeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DecodeToolStripMenuItem.Click
		radDecode.Enabled = True
	End Sub

	Private Sub txtInput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInput.TextChanged
		Static blnClicked As Boolean = False
		If blnClicked = False Then
			With txtInput
				.Text = ""
				.TextAlign = HorizontalAlignment.Left
			End With
		End If
	End Sub

	Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
		Close()
	End Sub
End Class

Was This Post Helpful? 0
  • +
  • -

#7 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1865
  • View blog
  • Posts: 20,278
  • Joined: 17-March 01

Re: "Coder" Program

Posted 20 December 2008 - 05:29 PM

You're going to have to tell us what your program is supposed to do and what errors you're getting. We're not mind readers.
Was This Post Helpful? 0
  • +
  • -

#8 coder001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 15-December 08

Re: "Coder" Program

Posted 20 December 2008 - 06:31 PM

View Postskyhawk133, on 20 Dec, 2008 - 04:29 PM, said:

You're going to have to tell us what your program is supposed to do and what errors you're getting. We're not mind readers.



Oh yeah sorry lol. I posted another post with the instructions, i just suppossed that you already read it.

Ok here are instructions: "Create a Coder application that encodes or decodes a messagge using Unicode."
So basically you type something in a textbox and then you click on an encode radio button or decode radio button and it will encode it from regular words to unicode. For decode you type in unicode and it turns it back into regular words.
And I'm not getting an error it just won't do anything
(I couldn't attatch the actual program to this post, it wouldn't let me)
Was This Post Helpful? 0
  • +
  • -

#9 coder001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 15-December 08

Re: "Coder" Program

Post icon  Posted 21 December 2008 - 09:36 AM

My program is called Coder (which many of you already know). Directions: Create a Coder application that encodes and decodes a message using Unicode.

Now I fixed the error but it still won't do anything. Can someone tell me why?

Public Class Form1
	Dim strMessage As String
	Dim strCodedMessage As String

	Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
		If radEncode.Checked = True Then
			strMessage = txtInput.Text

			If strMessage = Nothing Then
				MsgBox("Please enter a message to decode")
			Else
				For intNum As Integer = 0 To (strMessage.Length - 1)
					If strMessage.Chars(intNum) = "Y" Then
						strCodedMessage = strCodedMessage & "A" & " "
					ElseIf strMessage.Chars(intNum) = "Z" Then
						strCodedMessage = strCodedMessage & "B" & " "
					Else
						strCodedMessage = strCodedMessage & ChrW(AscW(strMessage.Chars(intNum)) + 2)
					End If
				Next
			End If
		End If
		txtInput.Text = strCodedMessage
		If strMessage = Nothing Then
			strCodedMessage = Nothing
		ElseIf radDecode.Checked = True Then

		End If
		strCodedMessage = txtInput.Text

		strCodedMessage.Trim(" ")
		strCodedMessage = strCodedMessage.PadRight(strCodedMessage.Length + 1)

		Dim intMax As Integer = strCodedMessage.Length - 1

		For intNum As Integer = 0 To intMax
			If strCodedMessage = "" Then

				If strCodedMessage.Chars(intNum) = "A" Then
					strMessage = strMessage & "Y"
					strCodedMessage = strCodedMessage.Remove(0, intNum + 1)
				ElseIf strCodedMessage.Chars(intNum) = "B" Then
					strMessage = strMessage & "Z"
					strCodedMessage = strCodedMessage.Remove(0, (intNum + 1))
				Else
					Dim strVar As String

					For intNum2 As Integer = 0 To (intNum)
						strVar = strVar & AscW(strCodedMessage.Chars(intNum2))
					Next
					Dim intVar = Val(strVar) - 2

					strMessage = strMessage & ChrW(intVar)

					strCodedMessage = strCodedMessage.Remove(0, 1)
					strVar = Nothing
				End If
				intNum = -1
				intMax = strCodedMessage.Length - 1
			End If
		Next

		txtInput.Text = strMessage

		strMessage = Nothing
		strCodedMessage = Nothing
	End Sub

	Private Sub EncodeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EncodeToolStripMenuItem.Click
		radEncode.Enabled = True
	End Sub

	Private Sub DecodeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DecodeToolStripMenuItem.Click
		radDecode.Enabled = True
	End Sub

	Private Sub txtInput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtInput.TextChanged
	  
	End Sub

	Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
		Close()
	End Sub

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	End Sub

	Private Sub radEncode_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radEncode.CheckedChanged
		If radEncode.Checked = True Then
			strMessage = txtInput.Text

			If strMessage = Nothing Then
				MsgBox("Please enter a message to decode")
			Else
				For intNum As Integer = 0 To (strMessage.Length - 1)
					If strMessage.Chars(intNum) = "Y" Then
						strCodedMessage = strCodedMessage & "A" & " "
					ElseIf strMessage.Chars(intNum) = "Z" Then
						strCodedMessage = strCodedMessage & "B" & " "
					Else
						strCodedMessage = strCodedMessage & ChrW(AscW(strMessage.Chars(intNum)) + 2)
					End If
				Next
			End If
		End If
		txtInput.Text = strCodedMessage

		If strMessage = Nothing Then
			strCodedMessage = Nothing
		ElseIf radDecode.Checked = True Then

		End If
		strCodedMessage = txtInput.Text

		strCodedMessage.Trim(" ")
		strCodedMessage = strCodedMessage.PadRight(strCodedMessage.Length + 1)

		Dim intMax As Integer = strCodedMessage.Length - 1

		For intNum As Integer = 0 To intMax
			If strCodedMessage = "" Then

				If strCodedMessage.Chars(intNum) = "A" Then
					strMessage = strMessage & "Y"
					strCodedMessage = strCodedMessage.Remove(0, intNum + 1)
				ElseIf strCodedMessage.Chars(intNum) = "B" Then
					strMessage = strMessage & "Z"
					strCodedMessage = strCodedMessage.Remove(0, (intNum + 1))
				Else
					Dim strVar As String

					For intNum2 As Integer = 0 To (intNum)
						strVar = strVar & AscW(strCodedMessage.Chars(intNum2))
					Next
					Dim intVar = Val(strVar) - 2

					strMessage = strMessage & ChrW(intVar)

					strCodedMessage = strCodedMessage.Remove(0, 1)
					strVar = Nothing
				End If
				intNum = -1
				intMax = strCodedMessage.Length - 1
			End If
		Next

		txtInput.Text = strMessage

		strMessage = Nothing
		strCodedMessage = Nothing
	End Sub

	Private Sub radDecode_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radDecode.CheckedChanged
		Static blnClicked As Boolean = False
		If blnClicked = False Then
			With txtInput
				.Text = ""
				.TextAlign = HorizontalAlignment.Left
			End With
		End If
	End Sub
End Class


I'm begging you guys, someone help me. I need to make this program work by tuesday
Was This Post Helpful? 0
  • +
  • -

#10 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: "Coder" Program

Posted 21 December 2008 - 10:57 AM

Please, you have started three threads regarding the same exact program, same exact questions, same exact code. Opening thread after thread isn't going to get you help any faster, all it's going to do is clutter the forum, and confuse those who are trying to help. Please do not start another thread regarding this issue :)
Was This Post Helpful? 0
  • +
  • -

#11 coder001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 15-December 08

Re: "Coder" Program

Posted 21 December 2008 - 11:39 AM

View PostPsychoCoder, on 21 Dec, 2008 - 09:57 AM, said:

Please, you have started three threads regarding the same exact program, same exact questions, same exact code. Opening thread after thread isn't going to get you help any faster, all it's going to do is clutter the forum, and confuse those who are trying to help. Please do not start another thread regarding this issue :)


Sorry, the last thread was a friend of mine doing it. Won't let it happen again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1