Here is some of the code I was playing with this morning.
Imports System
Imports System.Runtime.InteropServices
Namespace VBStrings
<Guid("89439AD1-756F-4f9c-BFB4-18236F63251E"), _
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface _VBStrings
<DispId(1)> Function GetDaysDiff(d1 As String, d2 As String) As Integer
<DispId(2)> Function PadXojoString(source As String, padChar As String, padCount As Integer) As String
<DispId(3)> Function AddDays(sDate As String, iDaysToAdd As Integer) As String
End Interface
<Guid("1376DE24-CC2D-46cb-8BF0-887A9CAF3014"), _
ClassInterface(ClassInterfaceType.None), _
ProgId("hdXojoStrings")> Public Class VBStrings
Implements _VBStrings
Public VBStrings()
Public Function GetDaysDiff(sDateStart As String, sDateEnd As String) As Integer Implements _VBStrings.GetDaysDiff
Dim diff As Integer = 0
Dim d1 As Date
Dim d2 As Date
Try
d1 = CDate(sDateStart)
Catch ex As Exception
diff = -1
End Try
Try
d2 = CDate(sDateEnd)
Catch ex As Exception
diff = -1
End Try
If diff = 0 Then
diff = DateDiff(DateInterval.Day, d1, d2)
End If
Return diff
End Function
Public Function PadXojoString(source As String, pChar As String, pCount As Integer) As String Implements _VBStrings.PadXojoString
Return source.PadLeft(pCount, pChar)
End Function
Public Function AddDays(sDate As String, iDaysToAdd As Integer) As String Implements _VBStrings.AddDays
Dim results As String = ""
Dim mDate As Date = Nothing
Try
mDate = CDate(sDate)
Catch ex As Exception
results = ex.Message
End Try
If results = "" Then
mDate = mDate.AddDays(iDaysToAdd)
results = mDate.ToShortDateString
End If
Return results
End Function
End Class
End Namespace
[quote=130527:@Johnny Harris]Here is some of the code I was playing with this morning.
[/quote]
Great. I was able to modify my project and now can pass strings back and forth. I do not know what happened before. Maybe I ran into the busy DLL file or something.
The important part is now I can tap into some of the .NET functions inaccessible to Xojo Win32.