4 Replies - 291 Views - Last Post: 26 February 2018 - 10:01 AM Rate Topic: -----

#1 underoathed   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-December 15

Checking to see if a date and time is 24 hours old

Posted 26 February 2018 - 07:17 AM

I have code that generates a verification code and is sent via email. I need to check whether or not the code creation date and time is either < 24 hours or > 24 hours. Everything but the evaluation of the 24 hours works. I have not started the code for that since I am at a loss here. Any help is appreciated

Dim CurrentDate As DateTime
	CurrentDate = DateTime.Now
	
	'This gets the randomly generated verification code
	For i As Integer = 1 To cnt
		Dim idx As Integer = r.Next(0, s.Length)
		sb.Append(s.Substring(idx, 1))
		
	'This generates another if the Resend Verification code button is clicked
	Next
	
	oWebUserGE.SetValue("VerificationCode__pbi", sb.ToString()) 
	
	oWebUserGE.SetValue("VerificationCodeCreationDateTime__pbi",CurrentDate) 
	oWebUserGE.Save()



Is This A Good Question/Topic? 0
  • +

Replies To: Checking to see if a date and time is 24 hours old

#2 andrewsw   User is offline

  • blow up my boots
  • member icon

Reputation: 6549
  • View blog
  • Posts: 26,553
  • Joined: 12-December 12

Re: Checking to see if a date and time is 24 hours old

Posted 26 February 2018 - 07:29 AM

Is this for VB6 or VB.NET? Looks very much like VB.NET to me.

What is the object oWebUserGE? What type is it?



A recent conversation on stackoverflow for reference.
Was This Post Helpful? 1
  • +
  • -

#3 underoathed   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-December 15

Re: Checking to see if a date and time is 24 hours old

Posted 26 February 2018 - 07:36 AM

View Postandrewsw, on 26 February 2018 - 07:29 AM, said:

Is this for VB6 or VB.NET? Looks very much like VB.NET to me.

What is the object oWebUserGE? What type is it?



A recent conversation on stackoverflow for reference.


Sorry this is VB.NET. As for the oWebUserGE here is the entire syntax which may answer all of these questions.

Try
	Dim oApp As Aptify.Framework.Application.AptifyApplication = New Aptify.Framework.Application.AptifyApplication(oDataAction.UserCredentials)
	Dim lWebUserID As Long = oProperties.GetProperty("WebUserID")
	Dim oWebUserGE As Aptify.Framework.BusinessLogic.GenericEntity.AptifyGenericEntityBase = oApp.GetEntityObject("Web Users", lWebUserID)
	Dim s As String = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstwxyz0123456789"
    Dim r As New System.Random
	Dim sb As New System.Text.StringBuilder
	Dim cnt As Integer = 8 'r.Next(15, 33)
	Dim CurrentDate As DateTime
	CurrentDate = DateTime.Now
	Dim results1 As String = "This Worked"
	Dim results2 As String = "This No work for you!"
	
	'This gets the randomly generated verification code
	For i As Integer = 1 To cnt
		Dim idx As Integer = r.Next(0, s.Length)
		sb.Append(s.Substring(idx, 1))
		
	'This generates another if the Resend Verification code button is clicked
	Next
	
	oWebUserGE.SetValue("VerificationCode__pbi", sb.ToString()) 
	
	oWebUserGE.SetValue("VerificationCodeCreationDateTime__pbi",CurrentDate) 
	oWebUserGE.Save()
	
	'Update the verification code creation date/time
	
	'NO?
	oResultCode.Value = "SUCCESS"
Catch ex As System.Exception
	oResultCode.Value = "FAILED"
End Try


This post has been edited by andrewsw: 26 February 2018 - 08:04 AM
Reason for edit:: fixed failed [code][/code] tags

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • blow up my boots
  • member icon

Reputation: 6549
  • View blog
  • Posts: 26,553
  • Joined: 12-December 12

Re: Checking to see if a date and time is 24 hours old

Posted 26 February 2018 - 08:05 AM

Moved to VB.NET forum.
Was This Post Helpful? 0
  • +
  • -

#5 underoathed   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-December 15

Re: Checking to see if a date and time is 24 hours old

Posted 26 February 2018 - 10:01 AM

Okay so I have gotten somewhere with my code. Now when I try to get the logic right in the if/else if/else statement I get this error message:

the message resource is present but the message is not found in the string/message table


Here is my code:

Try
	Dim oApp As Aptify.Framework.Application.AptifyApplication = New Aptify.Framework.Application.AptifyApplication(oDataAction.UserCredentials)
	Dim lWebUserID As Long = oProperties.GetProperty("WebUserID")
	Dim oWebUserGE As Aptify.Framework.BusinessLogic.GenericEntity.AptifyGenericEntityBase = oApp.GetEntityObject("Web Users", lWebUserID)
	Dim s As String = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstwxyz0123456789"
    Dim r As New System.Random
	Dim sb As New System.Text.StringBuilder
	Dim cnt As Integer = 8 'r.Next(15, 33)
	Dim CurrentDate As DateTime
	CurrentDate = DateTime.Now
	
	If oWebUserGE.GetValue("VerificationCodeCreationDateTime__pbi").addhours(24) < CurrentDate Then
		MsgBox("This is older than the current date")
	Else If oWebUserGE.GetValue("VerificationCodeCreationDateTime__pbi").addhours(24) > CurrentDate Then
		MsgBox("This is not older than the current date")
	Else If oWebUserGE.getvalue("VerificationCodeCreationDateTime__pbi") = Nothing Then
		oWebUserGE.SetValue("VerificationCodeCreationDateTime__pbi", 01/01/1900)
	End If
	
	'This gets the randomly generated verification code
	For i As Integer = 1 To cnt
		Dim idx As Integer = r.Next(0, s.Length)
		sb.Append(s.Substring(idx, 1))
		
	
	'This generates another if the Resend Verification code button is clicked
	Next
	
	oWebUserGE.SetValue("VerificationCode__pbi", sb.ToString()) 
	oWebUserGE.SetValue("VerificationCodeCreationDateTime__pbi",CurrentDate) 
	
	oWebUserGE.Save()
	
	'Update the verification code creation date/time
	
	'NO?
	
	oResultCode.Value = "SUCCESS"
Catch ex As System.Exception
	oResultCode.Value = "FAILED"
End Try


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1