Results 1 to 3 of 3

Thread: Converting VB.net code to VBA

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2012
    Posts
    24

    Converting VB.net code to VBA

    I have been working on vb for past few days..Its really interesting.But I wanna know how can we convert VB.net code to vba. A code which I wanna convert to VBA and run it as a macro. Please any help would be appreciative.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Converting VB.net code to VBA

    VB.NET provides far more functionality than VBA. Some code might be able to be translated as is, some might need a bit of tweaking and some might be all but impossible to replicate. It all depends on the specifics of the code.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2012
    Posts
    24

    Re: Converting VB.net code to VBA

    Thanks..code is something like the below.
    Code:
    Dim col As Integer = DGV.Columns.Count
    If col > 1 Then
    Dim start As Date = Date.Today.Add(New TimeSpan(0, 15, 0))
    Dim end As Date = Date.Today.Add(New TimeSpan(11, 15, 0))
    Dim cellV As String, cellD As Date
    For i As Integer = 1 To col - 1
    For Each row As DataGridViewRow In DGV.Rows
    cellV = row.Cells(i).Value.ToString
    If Date.TryParse(cellV, cellD) Then
    If cellD > start AndAlso cellD < end Then
    row.Cells(i).Style.BackColor = Color.brown
    End If
    End If
    Next
    Next
    End If
    Quote Originally Posted by jmcilhinney View Post
    VB.NET provides far more functionality than VBA. Some code might be able to be translated as is, some might need a bit of tweaking and some might be all but impossible to replicate. It all depends on the specifics of the code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width