Get build data

Post your Gambas programming questions here.
AndyGable
Posts: 58
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: Get build data

Post by AndyGable » Wednesday 24th February 2021 3:20pm

Code: Select all

' Gambas class file
Public Sub Form_Open()
	Me.labApplicationVersion.Text = "Application Version : " & Application.Version
	getBuildDate
End

Private Sub getBuildDate()
	Dim sText As String = "no "
	Dim spath As String = Application.Path & "/" Application.Name & ".Gambas"  
	If Exist(sPath) Then sPath = Format(Stat(sPath).LastModified, DD dd mmm yyyy)
	Me.labBuildDate.Text = Build Date: " & " sText
End
That is my code from the application

User avatar
cogier
Site Admin
Posts: 674
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Get build data

Post by cogier » Wednesday 24th February 2021 4:00pm

OK there is a few things here.

1/. When posting code use the 'gb' button, it's much nicer :D
2/. &/ is a powerful command that sorts out if you need, or don't need, a slash in the path. The following will work sPath = "/usr/" &/ "/bin/" &/ "/amidi"
3/. Dim spath As String = Application.Path & "/" Application.Name & ".Gambas", You changed "gambas" to "Gambas". The file ending is ".gambas"
4/. Me.labApplicationVersion.Text, just labApplicationVersion.Text will do.
5/. If Exist(sPath) Then sPath = Format(Stat(sPath).LastModified, DD dd mmm yyyy). The DD dd mmm yyyy needs to be in inverted commas "DD dd mmm yyyy" and sPath needs to be sText
6/. Me.labBuildDate.Text = Build Date: " & " sText. Again "Me." is not required, and you have got your inverted commas muddled.

Try this: -
Public Sub Form_Open()

  labApplicationVersion.Text = "Application Version : " & Application.Version
  getBuildDate

End

Private Sub getBuildDate()

  Dim sText As String = "no "
  Dim sPath As String = Application.Path &/ Application.Name & ".gambas"

  If Exist(sPath) Then sText = Format(Stat(sPath).LastModified, "DD dd mmm yyyy")
  labBuildDate.Text = "Build Date: " & sText

End

AndyGable
Posts: 58
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: Get build data

Post by AndyGable » Wednesday 24th February 2021 9:16pm

Hi Cogier,

Thanks so much for sorting my code I am still finding myself working in VB.net (as I am porting my application across from that to Gambas)

I use to work in VB6 for a long time and then moved to vb.net I should have moved to Gambas then but for some reason I moved to .NET (big mistake) now I am getting my head around Gambas I really like it

on the date side is it possible to have it show like

Monday 1st February 2021 and not Monday 1 February 20201?

User avatar
cogier
Site Admin
Posts: 674
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Get build data

Post by cogier » Thursday 25th February 2021 10:39am

AndyGable wrote:
Wednesday 24th February 2021 9:16pm
...on the date side is it possible to have it show like

Monday 1st February 2021 and not Monday 1 February 20201?
The quick answer is yes, but you need to create the code to do it. Try this: -
Public Sub Form_Open()

  labApplicationVersion.Text = "Application Version : " & Application.Version
  getBuildDate

End

Private Sub getBuildDate()

  Dim sText As String = "no "
  Dim sPath As String = Application.Path &/ Application.Name & ".gambas"
  Dim sOrdinal As String

  If Exist(sPath) Then
    sOrdinal = GetOrdinal(Format(Stat(sPath).LastModified, "d"))
    sText = Format(Stat(sPath).LastModified, "dddd d") & sOrdinal & Format(Stat(sPath).LastModified, " mmm yyyy")
  End If

  labBuildDate.Text = "Build Date: " & sText

End

Public Sub GetOrdinal(sDay As String) As String

   Select Case sDay
    Case "1", "21", "31"
      Return "st"
    Case "2", "22"
      Return "nd"
    Case "3", "23"
      Return "rd"
  End Select

  Return "th"

End

Post Reply