1 Replies - 1904 Views - Last Post: 14 January 2010 - 05:15 AM Rate Topic: -----

#1 freznelzone  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-January 10

how to call a function in vb.net using vb6

Post icon  Posted 14 January 2010 - 01:59 AM

Imports System.IO
Imports System.Diagnostics
Imports System.Data.OleDb

<ComClass(API.ClassId, API.InterfaceId, API.EventsId)> _
Public Class API
Dim apicon As New System.Data.OleDb.OleDbConnection()
Dim apicmd As System.Data.OleDb.OleDbCommand
Dim dr_api As System.Data.OleDb.OleDbDataReader
Dim apiconstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + My.Application.Info.DirectoryPath + "\mydb.mdb;Jet OLEDB:Database Password=xxxxxxxx"



#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "1bea8343-c986-4e52-a8d7-07c6b93ab328"
Public Const InterfaceId As String = "8f2efc3b-e5b7-41a2-a727-bf6db1796d76"
Public Const EventsId As String = "ef4277dc-4322-4b5c-b983-dd059c73df68"
#End Region

' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub

Private Function clean_text(ByVal mytext As String) As String
Dim mystr As String

mystr = Replace$(mytext, "'", "''")
mystr = Replace$(mystr, "\", "\\")
clean_text = mystr

End Function

Public Function SendMsg(ByVal mobileno As String, ByVal message As String) As Integer
Dim MySQLQuery As String = "INSERT INTO sms_qoutbox (DateTimeIN,MobileNo,Message,Status,Notes1,Notes2) VALUES(Now(),'" + clean_text(mobileno) + "','" + clean_text(message) + "','FSP','None','None')"
Try
If apicon.State = Data.ConnectionState.Open Then apicon.Close()
apicon.ConnectionString = apiconstr
apicon.Open()
apicmd = New OleDbCommand(MySQLQuery, apicon)
apicmd.ExecuteNonQuery()
apicon.Close()
apicmd.Dispose()
Return 0
Catch ex As Exception
Return 1
End Try
End Function

Public Function FetchMsg() As String()
Dim SMSMsg(3) As String
Dim myid As String = ""
Dim MySQLQuery As String = "SELECT TOP 1 * FROM sms_inbox"
Try
If apicon.State = Data.ConnectionState.Open Then apicon.Close()
apicon.ConnectionString = apiconstr
apicon.Open()
apicmd = New OleDbCommand(MySQLQuery, apicon)
dr_api = apicmd.ExecuteReader
While dr_api.Read()
myid = dr_api(0).ToString
SMSMsg(0) = dr_api(1).ToString
SMSMsg(1) = dr_api(2).ToString
SMSMsg(2) = dr_api(3).ToString
End While
dr_api.Close()
apicon.Close()
apicmd.Dispose()
If myid = "" Then
SMSMsg(0) = ""
SMSMsg(1) = ""
SMSMsg(2) = ""
End If
MySQLQuery = "DELETE FROM sms_inbox WHERE ID=" + myid
apicon.ConnectionString = apiconstr
apicon.Open()
apicmd = New OleDbCommand(MySQLQuery, apicon)
apicmd.ExecuteNonQuery()
apicon.Close()
apicmd.Dispose()
Return SMSMsg
Catch ex As Exception
SMSMsg(0) = ""
SMSMsg(1) = ""
SMSMsg(2) = ""
Return SMSMsg
End Try
End Function

Public Function ClearSentItems() As Integer
Dim MySQLQuery As String = "DELETE FROM sms_outbox"
Try
If apicon.State = Data.ConnectionState.Open Then apicon.Close()
apicon.ConnectionString = apiconstr
apicon.Open()
apicmd = New OleDbCommand(MySQLQuery, apicon)
apicmd.ExecuteNonQuery()
apicon.Close()
apicmd.Dispose()
Return 0
Catch ex As Exception
Return 1
End Try
End Function

End Class

Is This A Good Question/Topic? 0
  • +

Replies To: how to call a function in vb.net using vb6

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 463
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: how to call a function in vb.net using vb6

Posted 14 January 2010 - 05:15 AM

hello :)

can you pls post the question in the body not in description. pls post your code in tags like so
:code:

do you mean calling a dll on vb.net in vb6 project?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1