Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:37:03+00:00 2026-06-09T12:37:03+00:00

I am trying to convert the code below from VB6 to C#. I am

  • 0

I am trying to convert the code below from VB6 to C#. I am just not sure where to begin, I guess maybe because I am sucked way to much into VB6 and can’t seem to take a step back.

Private Function GMT_OFFSET() As Integer
    '****DECLARE VARIABLES
    Dim dtNow As Date, dtEngland As Date
    Dim dtGMT As SYSTEMTIME
    '****GET SYSTEM TIME INFORMATION
    Call GetSystemTime(dtGMT)
    dtNow = Now
    dtEngland = dtGMT.wYear & "-" & dtGMT.wMonth & "-" & dtGMT.wDay & " " & dtGMT.wHour & ":" & dtGMT.wMinute & ":" & dtGMT.wSecond
    '****RETURN QUARTER HOURS
    GMT_OFFSET = DateDiff("n", dtEngland, dtNow) \ 15
End Function

I know GetSystemTime is a Win32 API, obviously don’t want to do PInvoke in .NET but rather use the pure objects in the .NET Framework.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:37:05+00:00Added an answer on June 9, 2026 at 12:37 pm

    Near direct translation:

    //Private Function GMT_OFFSET() As Integer
    int GMT_OFFSET()
    {
      //'****DECLARE VARIABLES
      //Dim dtNow As Date, dtEngland As Date
      DateTime dtNow, dtEngland;
      //Dim dtGMT As SYSTEMTIME
      //'****GET SYSTEM TIME INFORMATION
      //Call GetSystemTime(dtGMT)
      //dtNow = Now
      //dtEngland = dtGMT.wYear & "-" & dtGMT.wMonth & "-" & dtGMT.wDay & " " & dtGMT.wHour & ":" & dtGMT.wMinute & ":" & dtGMT.wSecond
      dtEngland = DateTime.UtcNow;
      dtNow = dtEngland.ToLocalTime;
      //'****RETURN QUARTER HOURS
      //GMT_OFFSET = DateDiff("n", dtEngland, dtNow) \ 15
      return Convert.ToInt32((dtNow - dtEngland).TotalMinutes) / 15;
    //End Function
    }
    

    NB VB6’s DateDiff(interval,date1,date2) results in intervals based upon date2 - date1, not vice versa.

    But the one-liner is:

    return Convert.ToInt32(TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow).TotalMinutes) / 15;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert the code below to a lambda expression from b
Any help would be appreciated, I'm trying to convert the code below to C#,
I'm trying to convert the below bit of code into VB (and obviously apply
I'm trying to convert some code from Richfaces 4 showcase to use CDI instead
I've been trying to convert a PHP code to Java, but its not working
I am trying to convert the following code from Trefethen's Spectral Methods in MATLAB
Im attempting to Convert a Price (from an API (code below)). public class Price
I'm trying to convert the vb code (below) to c#. The c# code a
I am trying to scrap some content from a website but the code below
The code below does not compile. The compiler error is Cannot implicitly convert type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.