Duplicated??
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts
Page 1 of 1
Hello,
we wanted to add date and time only once when the string are the same
if not then add it
but now it seems it works fine but when the date or time change i get duplicated strings
for example we have lets say 5 records with the date:
6/6/2000 16:00 PM
-- works fine it only add it 1x instead of 5x
for example we have lets say 1 records with the time:
6/6/2000 16:01 PM
-- we get it 2x instead of 1x
here the code we used:
thanks
we wanted to add date and time only once when the string are the same
if not then add it
but now it seems it works fine but when the date or time change i get duplicated strings
for example we have lets say 5 records with the date:
6/6/2000 16:00 PM
-- works fine it only add it 1x instead of 5x
for example we have lets say 1 records with the time:
6/6/2000 16:01 PM
-- we get it 2x instead of 1x
here the code we used:
Code: Select all
what are we doing wrong? Dim cd As New LblDateTime
With cd 'set date time
If date_ = Date.Today.ToString("MM-dd-yyyy") Then
.FlatLabel1.Text = "Today at " & time_
Else
.FlatLabel1.Text = date_ & " at " & time_
End If
End With
Dim _ButtonExists As Boolean = False
Try
For Each FoundButton As LblDateTime In FlowLayoutPanel2.Controls
If FoundButton.FlatLabel1.Text.Contains(date_ & " at " & time_) Or FoundButton.FlatLabel1.Text.Contains("Today at " & time_) Then
_ButtonExists = True
Exit For
End If
Next
Catch ex As Exception
End Try
If Not _ButtonExists Then
FlowLayoutPanel2.Controls.Add(cd) ' add it when not exist
Else
FlowLayoutPanel2.Controls.Remove(cd) ' remove duplicated once
End If
thanks
You do not have the required permissions to view the files attached to this post.
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Just by looking at that code, I can't seem to find anything wrong with it. Would you mind posting a little more code, or perhaps an executable file so that I can try and reproduce the problem?
we have solved the problem 
thanks guys.
seems to use a dictionary can help you alot :lol:
the solution:

thanks guys.
seems to use a dictionary can help you alot :lol:
the solution:
Code: Select all
Public LastDates As New Dictionary(Of String, String)
If LastDates.ContainsKey(date_time) Then
FrmInbox.FlowLayoutPanel2.Controls.Remove(cd)
Else
LastDates.Add(date_time, "")
End If
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023