Visual Basic - Funcion tiempo

Life is soft - evento anual de software empresarial
   
Vista:

Funcion tiempo

Publicado por Pilar (7 intervenciones) el 05/04/2014 12:28:47
Hola, tengo que hacer un programa que en un array me guarde (URL,descripción,tiempo), es decir que me indique en un cuadro de lectura según unas condiciones un texto, que indica los intervalos de tiempo. Pero tengo un problema con los tiempos, ya que no coinciden. A ver si me pueden echar una mano.

'Array favourites websites
<Serializable> Structure FavouriteData
Dim ShoAddress As String
Dim ShoURL As String
Dim ShoTime As Date

'Subrutine to create a favourite list
Public Sub New(ByVal NameAddress As String, ByVal URLAddress As String, ByVal LastAccessed As Date)
ShoAddress = NameAddress
ShoURL = URLAddress
ShoTime = LastAccessed
End Sub
End Structure

Private ShortAddressInfo(100) As FavouriteData

Private Sub BtnAdd_Click(sender As Object, e As EventArgs) Handles BtnAdd.Click
'Add Favourites Web Site to list

'Local Variables
Dim ShortAddress As String
Dim ShortURL As String
Dim ShortTime As Date
Dim ComboIndex As Integer


ShortAddress = InputBox("Enter a Short Description of the Favourite Web Site", "Short Description")
If ShortAddress = "" Then GoTo CancelEntry
ShortTime = Now
ShortURL = TextURL.Text
'Add Favourites to ComboBox and Short Description
CbFavourites.BeginUpdate()
CbFavourites.Items.Add(ShortAddress)
CbFavourites.Text = ShortAddress
CbFavourites.EndUpdate()

ComboIndex = CbFavourites.SelectedIndex

ShortAddressInfo(ComboIndex) = New FavouriteData(ShortAddress, ShortURL, ShortTime)

CancelEntry:
End Sub


Private Sub CbFavourites_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CbFavourites.SelectedIndexChanged

Dim IndexValue As Integer
Dim DateDiff As TimeSpan
Dim TimeVisit As Integer

IndexValue = CbFavourites.SelectedIndex
DateDiff = Now - ShortAddressInfo(IndexValue).ShoTime
TimeVisit = DateDiff.Days
If TimeVisit < 1 Then
TextLastAccessed.Text = "Less than 24 hours ago"
Else
If TimeVisit = 1 Then
TextLastAccessed.Text = "1 day ago"
Else
If TimeVisit > 1 And TimeVisit < 366 Then
TextLastAccessed.Text = TimeVisit & " days ago"
Else
TextLastAccessed.Text = "More than 1 year"
End If
End If
End If
If (ShortAddressInfo(IndexValue).ShoURL <> "") Then
TextURL.Text = ShortAddressInfo(IndexValue).ShoURL
Call WbBrowser.Navigate(TextURL.Text)
End If
End Sub


Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder