Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expression Assistance Please

Status
Not open for further replies.

linuxjr

Programmer
Jun 2, 2001
135
0
0
US
I am finally gotten everything done with my data entry form except I am having one quirk that is giving me a hard time.

I have a drop down on the form with values lets just say city1, city2, city3 and when the user selects one of these values it populates a textbox with the value. I'm trying to figure how to search and replace the city value's if the user changes his/her mind.

The user selects City1 then my textbox will say:

You have selected City1

but when the user goes oh I meant city two the textbox will then have:

You have selected City1
You have selected City2

I figured the simple solution would be to use a regular expression to parse through my multiline textbox and replace the string. If anyone has any tips or suggestions that I can research how to do this it will be greatly appreciated. Have a great day.
 
Cant you just clear the textbox before entering the text?
 
If you have AutoPostBack set to True on your DropDownList then you shouldn't need to append to the Textbox (you should just set the Text). e.g.
Code:
<asp:dropdownlist id="DropDownList1" runat="server" AutoPostBack="True">
				<asp:ListItem Value="City1">City1</asp:ListItem>
				<asp:ListItem Value="City2">City2</asp:ListItem>
</asp:dropdownlist>
and:
Code:
    Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        TextBox1.Text = "You selected " & DropDownList1.SelectedItem.Value
    End Sub

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Shatch and Ca8msm,

Thanks for the quick Responses. I should add a little more to the problem I am having:

The text box I'm writing to is a Multi-Line Problem Description Text Box. I have a simple Drop Down Box filled with Status's. I was just using Cities as an example in my original post. Anyways the user could type a good bit of information about the problem in the text box.

So for example:

Status: Machine Down <- Appended by the Select Index Changed
Machine A is not powering up. I think the power supply needs to be replaced.

The user can change the text if he/she wants to but I'm also trying to take in account they will use the drop down to make the change. It will then just append the new status at the bottom of the text:

Status: Machine Down
Machine A is not powering up. I think the power supply needs to be replaced.
Status: Power Supply is Bad

I hope this explains my problem a little better. Again any tips or suggestions be appreciated. Have a great day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top