Click here to Skip to main content
15,881,812 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Fade in and fade out the page Pin
Abhishek Sur18-Nov-09 21:25
professionalAbhishek Sur18-Nov-09 21:25 
QuestionReferance error Pin
Sagar.H.Mistry18-Nov-09 17:58
Sagar.H.Mistry18-Nov-09 17:58 
AnswerRe: Referance error Pin
Abhijit Jana18-Nov-09 18:06
professionalAbhijit Jana18-Nov-09 18:06 
QuestionTFS BuildDefinition - Environment based dlls Pin
student_rhr18-Nov-09 12:50
student_rhr18-Nov-09 12:50 
AnswerRe: TFS BuildDefinition - Environment based dlls Pin
The Man from U.N.C.L.E.18-Nov-09 13:28
The Man from U.N.C.L.E.18-Nov-09 13:28 
GeneralRe: TFS BuildDefinition - Environment based dlls Pin
student_rhr18-Nov-09 13:40
student_rhr18-Nov-09 13:40 
GeneralRe: TFS BuildDefinition - Environment based dlls Pin
The Man from U.N.C.L.E.18-Nov-09 22:10
The Man from U.N.C.L.E.18-Nov-09 22:10 
QuestionRemove character from string problem ASP.NET VB Pin
rbren9018-Nov-09 12:22
rbren9018-Nov-09 12:22 
Hi there..

I basically need the following form:
1. Ask user to input a string/word using a text control
2. Ask user to input characters they want removed from the string/word using another text control
3. Display the original string with specified characters removed in reverse order
4. Display removed characters

Using the following code I have created this which almost works:
<%@ Page Language="VB" Debug="true" %><br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
<title>Reverse Text</title><br />
<script runat="server"><br />
	Sub btnSubmit_OnClick(ByVal Sender As Object, ByVal E As EventArgs)<br />
        Dim lsReverse As String = txtReverse.Text<br />
        Dim lsExclude As String = txtExclude.Text<br />
        Dim lnExcludeLength As Integer = lsExclude.Length<br />
        Dim lnReverseLength As Integer = lsReverse.Length<br />
        Dim lnMaxLength As Integer = (lnReverseLength - lnExcludeLength) + 1<br />
        Dim lsNewTextArray(lnReverseLength) As String<br />
        Dim lsExcludedTextArray(lnExcludeLength) As String<br />
        Dim item As String<br />
        Dim lsReverseArray() As Char = txtReverse.Text.ToCharArray<br />
        Dim lsExcludeArray() As Char = txtExclude.Text.ToCharArray<br />
        Dim revcount As Integer = lsReverseArray.Length - 1<br />
        Dim excount As Integer = lsExcludeArray.Length - 1<br />
        Dim newcount As Integer = lsReverseArray.Length - lsExcludeArray.Length - 1<br />
       <br />
<br />
        For Each item In lsExcludeArray<br />
            <br />
            Do While revcount >= 0<br />
                If item = lsReverseArray(revcount) Then<br />
                    lsExcludedTextArray(excount) = item<br />
                    revcount = revcount - 1<br />
                    excount = -1<br />
                Else<br />
   [line35]         lsNewTextArray(newcount) = lsReverseArray(revcount)<br />
                    newcount = newcount - 1<br />
                    revcount = revcount - 1<br />
                    <br />
                End If<br />
            Loop<br />
        Next<br />
        <br />
        Dim i As Integer = lsNewTextArray.Length - 1<br />
        lblReversed.Text = ""<br />
        Do While i >= 0<br />
            lblReversed.Text = lblReversed.Text & lsNewTextArray(i)<br />
            i = i - 1<br />
        Loop<br />
        <br />
        lblExcluded.Text = lsExcludedTextArray(0)<br />
        <br />
    End Sub<br />
    <br />
</script><br />
</head><br />
<br />
<body><br />
<br />
<form id="frmReverseText" runat="server"><br />
				<asp:TextBox runat="server" id="txtReverse"></asp:TextBox><br />
				<br /><br />
				<br /><br />
				<asp:TextBox runat="server" id="txtExclude"></asp:TextBox><br />
				<br /><br />
				<br /><br />
				<asp:Button runat="server" OnClick="btnSubmit_OnClick" Text="Submit" id="btnSubmit" /><br />
				<br /><br />
				<br /><br />
				<asp:Label runat="server" Text="" id="lblReversed"></asp:Label><br />
				<br /><br />
				<asp:Label runat="server" Text="" id="lblExcluded"></asp:Label><br />
</form><br />
<br />
</body><br />
<br />
</html>


This code reversed the text and removes the character specified
HOWEVER! - if the user inputs more than 1 character to remove from the string, an error occurs:
"Index was outside the bounds of the array. (Line 35 which is pointed out above)."

A similar error occurs if there are two of the same character within the original string (e.g. 123455)

Can anyone help me to find a way around this? Hopefully my code is easy enough to read.

Thanks in advance
RB
AnswerRe: Remove character from string problem ASP.NET VB Pin
PunkIsNotDead18-Nov-09 13:42
PunkIsNotDead18-Nov-09 13:42 
Questionchild listview Pin
Tauseef A18-Nov-09 11:59
Tauseef A18-Nov-09 11:59 
QuestionUser Controls Pin
samir8018-Nov-09 11:17
samir8018-Nov-09 11:17 
AnswerRe: User Controls Pin
Abhishek Sur18-Nov-09 11:27
professionalAbhishek Sur18-Nov-09 11:27 
Questionwhen you have an example explain it properly please. Pin
macupryk18-Nov-09 10:26
macupryk18-Nov-09 10:26 
AnswerRe: when you have an example explain it properly please. Pin
Abhishek Sur18-Nov-09 10:57
professionalAbhishek Sur18-Nov-09 10:57 
GeneralRe: when you have an example explain it properly please. Pin
macupryk18-Nov-09 11:12
macupryk18-Nov-09 11:12 
GeneralRe: when you have an example explain it properly please. Pin
Abhishek Sur18-Nov-09 11:25
professionalAbhishek Sur18-Nov-09 11:25 
GeneralRe: when you have an example explain it properly please. Pin
macupryk19-Nov-09 1:03
macupryk19-Nov-09 1:03 
QuestionOnclick execute multiple functions mixed .net and javascript functions Pin
WizTAK18-Nov-09 10:06
WizTAK18-Nov-09 10:06 
AnswerRe: Onclick execute multiple functions mixed .net and javascript functions Pin
Abhishek Sur18-Nov-09 11:01
professionalAbhishek Sur18-Nov-09 11:01 
AnswerRe: Onclick execute multiple functions mixed .net and javascript functions Pin
PunkIsNotDead18-Nov-09 12:43
PunkIsNotDead18-Nov-09 12:43 
Questionlistview issue [modified] Pin
Tauseef A18-Nov-09 7:33
Tauseef A18-Nov-09 7:33 
AnswerRe: listview issue Pin
Abhishek Sur18-Nov-09 7:41
professionalAbhishek Sur18-Nov-09 7:41 
QuestionRe: listview issue Pin
Tauseef A18-Nov-09 12:02
Tauseef A18-Nov-09 12:02 
AnswerRe: listview issue Pin
Abhishek Sur18-Nov-09 23:13
professionalAbhishek Sur18-Nov-09 23:13 
AnswerRe: listview issue Pin
ranjan_namitaputra18-Nov-09 8:34
ranjan_namitaputra18-Nov-09 8:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.