• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 660
  • Last Modified:

Anyone can explain what does these codes do? [VB]

Hi,

I'm very new to VB, can anyone pls explain what does these codes do?

_______________________________________________________________________________
Public Sub syn_time()
Dim xsec%, xmin%, xhour%, xday%, xmonth%, xyear%
Dim x, y, z As Object
Dim strdate As String, strtime As String

On Error GoTo xerr

Set x = gTagDb.GetTag("xTIME\SECOND")
Set y = gTagDb.GetTag("xTIME\MINUTE")
Set z = gTagDb.GetTag("xTIME\HOUR")

strtime = Str(z) & ":" & Str(y) & ":" & Str(x)
'Time = strtime

Set x = gTagDb.GetTag("xTIME\MONTH")
Set y = gTagDb.GetTag("xTIME\DAY")
Set z = gTagDb.GetTag("xTIME\YEAR")

strdate = Str(x) & "/" & Str(y) & "/" & Str(z) 'mm/dd/yyyy
'Date = strdate
xerr:
End Sub
________________________________________________________________________________

Thanks. Appreciate :)
0
ckchew666
Asked:
ckchew666
2 Solutions
 
PodExpertCommented:
The code just picks up date and time information from database (probably GAP4 DNA Assembly program database) and puts it in Date and Time variables (probably for further processing). That's all.
0
 
bochgochCommented:
...Uses the GetTag function to extract time / date elements from a global - gTagDb, and then builds strings containing the appropriatelty formatted strings...

GetTag is not a core VB function, there is a VBA scripting language extension called CIMScan that has this function. Alternatively this may be a function developed in your App., take a look for the code!

0
 
stumpy1Commented:
I have put explanatory comments in code below.
Public Sub syn_time()
Dim xsec%, xmin%, xhour%, xday%, xmonth%, xyear%
Dim x, y, z As Object
Dim strdate As String, strtime As String

On Error GoTo xerr

Set x = gTagDb.GetTag("xTIME\SECOND") 'Gets second value from xTIME and assigning to x
Set y = gTagDb.GetTag("xTIME\MINUTE") 'Gets minute value from xTIME and assigning to y
Set z = gTagDb.GetTag("xTIME\HOUR") 'Gets hour value from xTIME and assigning to z

strtime = Str(z) & ":" & Str(y) & ":" & Str(x) 'formats the time as hour:min:sec, eg 10:51:01
'Time = strtime

Set x = gTagDb.GetTag("xTIME\MONTH") 'Gets month value from xTIME and assigning to x
Set y = gTagDb.GetTag("xTIME\DAY") 'Gets day value from xTIME and assigning to y
Set z = gTagDb.GetTag("xTIME\YEAR") 'Gets year value from xTIME and assigning to z

strdate = Str(x) & "/" & Str(y) & "/" & Str(z) 'mm/dd/yyyy 'formats the date as month/day/year, eg 11/09/2004
'Date = strdate
xerr:
End Sub

I dont know what the definition or xTIME is so a certain amount of thgis is guesswork
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now