-
February 21st, 2014, 10:07 AM
#1
isPalendrome function
Hi folks, just need some help with code :
need to create a code with isPalendrome function to check if given string is palendrome or not.
this is my code , something wrong in there. Could you please help?
thanks.
Code:
Function isPalendrome(ByVal Input As String, ByVal Reverse As String) As Boolean
isPalendrome = (Input = Reverse)
End Function
Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
Dim strInput As String
Dim StrReverse As String
Dim Outcome As String
strInput = txtString.Text
If Outcome = isPalendrome(strInput, StrReverse) Then
MsgBox(Outcome, "Is Palindrome!")
Else
MsgBox(Outcome, "Is Not Palindrome!")
End If
End Sub
-
February 21st, 2014, 12:01 PM
#2
Re: isPalendrome function
No such thing as
The function should just return a FLAG. You are going about it the wrong way. Don't try to reverse the original string. Create a copy, and reverse that.
-
February 21st, 2014, 08:21 PM
#3
Re: isPalendrome function
Here's a function to reverse text if you need one:
# Private Function Reverse(ByVal Input As String)
Dim CharNbr As Int16, ReverseString As String
Dim StringArray() As Char = Input.ToCharArray
For CharNbr = UBound(StringArray) To 0 Step -1
ReverseString &= StringArray(CharNbr)
Next
Return ReverseString
End Function
#
-
February 21st, 2014, 09:29 PM
#4
Re: isPalendrome function
That is for numbers, not text
-
February 21st, 2014, 09:36 PM
#5
Re: isPalendrome function
Not sure I understand you. The original post wanted to reverse a string and that's what the function does.
-
February 22nd, 2014, 01:38 PM
#6
Re: isPalendrome function
My mistake. Sorry.
You probably get an A+ on the quiz
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|