-
Mar 30th, 2014, 06:55 PM
#1
Thread Starter
Fanatic Member
find date in string replace with new date
i have a string for example:
%X %N SHIP 3/30/2014
i have a datetimepicker to choose the date, if i choose a date, it gets added to the string.
i have a checkbox that if checked, it will add the date to the string
but if i uncheck the checkbox, i would like to remove the date from the string or if i change the date in the datetimepicker i would like to change the date in the string.
any suggestions?
maybe with regex, but i don't know enough about regex to do it that way.
-
Mar 30th, 2014, 07:00 PM
#2
Re: find date in string replace with new date
How about you always keep the root value, i.e. the text without the date, in another String variable? Whenever you need to change the current text, just copy that String, either as is or with the selected date appended.
-
Mar 30th, 2014, 07:26 PM
#3
Thread Starter
Fanatic Member
Re: find date in string replace with new date
hmmm. i will play with that idea, but it gets a little tricky because the user can manually enter text into the text box.
-
Mar 30th, 2014, 07:29 PM
#4
Thread Starter
Fanatic Member
Re: find date in string replace with new date
i will use two variables. one for the text with out the date and one for the date
-
Mar 30th, 2014, 07:50 PM
#5
Re: find date in string replace with new date
Originally Posted by bezaman
hmmm. i will play with that idea, but it gets a little tricky because the user can manually enter text into the text box.
So, are you saying that you are appending the date to the actual contents of the TextBox, i.e. the date is displayed in the TextBox? That is a bit flawed because the user could then add more text after the date and then you would be appending a second date.
-
Mar 30th, 2014, 08:23 PM
#6
Thread Starter
Fanatic Member
Re: find date in string replace with new date
exactly. but i think i got it working pretty good.
-
Mar 30th, 2014, 08:25 PM
#7
Thread Starter
Fanatic Member
Re: find date in string replace with new date
form load
Code:
Me.InfoLine2Text = Me.TextBoxInfoLine2.Text
Me.InfoLine2Date = "SHIP " & Me.DateTimePickerDropDate.Text
Me.CheckBoxUseDropDate.Checked = True
Code:
Private Sub DateTimePickerDropDate_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePickerDropDate.ValueChanged
Me.InfoLine2Date = "SHIP " & Me.DateTimePickerDropDate.Text
If Me.CheckBoxUseDropDate.Checked = True Then
Me.TextBoxInfoLine2.Text = Me.InfoLine2Text & " " & Me.InfoLine2Date
End If
End Sub
Code:
Private Sub CheckBoxUseDropDate_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxUseDropDate.CheckedChanged
If Me.CheckBoxUseDropDate.Checked = True Then
Me.TextBoxInfoLine2.Text = Me.InfoLine2Text & " " & Me.InfoLine2Date
ElseIf Me.CheckBoxUseDropDate.Checked = False Then
Me.TextBoxInfoLine2.Text = Me.InfoLine2Text
End If
End Sub
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
|