Archive for the ‘VB Coding’ Category

Creating Windows Standard Dynamic Link Library (DLL) to Use with VB6 and Meta Trader (MT4)

Here are some simple steps to create a DLL to use with Meta Trader 4 or VB6.

NOTE: I assume that you have basic programming knowledge.

  1. Download Free Basic Here
  2. Install Free Basic in its default Location. You can read here about FreeBasic.
  3. Free Basic is free programming language to write programs like in MS VB.
  4. After installing FreeBasic, now write your dll code. For example open your favorite text editor and type the following sample code:
  5. 
    extern "windows-ms"
    
    function Add( byval x as integer, byval y as integer ) as integer export
      function = x + y
    end function
    
    function subtraction(byval x as integer, byval y as integer) as integer export
      function = x - y
    end function
    
    function divide(byval x as integer, byval y as integer) as double export
      function = x / y
    end function
    
    function multi(byval x as integer, byval y as integer) as integer export
      function = x * y
    end function
    
    function square(byval x as integer) as integer export
      function = x * x
    end function
    
    function cube(byval x as integer) as integer export
      function = x * x * x
    end function
    
    end extern
    
  6. All your functions should be between the commands [extern "windows-ms"] and [end extern].
  7. Now save the file as “mathlib.bas”. DOWNLOAD HERE sample file and DLL. As we have math functions so we are giving mathlib name, you can give it any other name. If you did not set your path variable to free basic then save file in folder: c:freebasicfreebasicmathlib.bas
  8. Now open DOS command prompt and change directory to:
  9. c:freebasicfreebasic

  10. Now type the following command to compile your file into dll.
  11. c:freebasicfreebasic>fbc -dll mathlib.bas
  12. This will create a mathlib.dll file. Now you can use this dll with any windows application like Meta Trader 4 or VB6.
  13. NOTE: If you have set your path variable to freebasic, then you can invoke “fbc” command from any directory.

Searched By:

mql4 dll (3), freebasic dll mt4 (3), freebasic dll (2), mt4 api dll (2), freebasic extern function (2), visual basic 6 soap (2), freebasic dll for vb net (2), mt4 vb6 (2), mql4 dll c# (2), mql4 dll sample (2), vb2010 export standard api dll (2), MT4 DLL create window (1), mt4 dll freebasic (1), mt4 dll use (1), mt4 dll vb (1), mt4 to vb net (1), mql4 export functinos (1), mt4 dll basic (1), mql4 msgbox (1), mql4 soap (1)

Adding web reference(wsdl service) to visual basic 6 using microsoft soap type library

In many cases, Visual Basic 6 developers need to add web reference and its not that easy. Here is an example that how you can add web service reference(wsdl service). To run this example code you need to add reference of Microsoft Soap Type Library and Microsoft XML,
V3.0 to your project. As there are comments to explain everything so its easy to change according to your needs.
Use commands which your wsdl service provides. This example code is for to get Quotes from Marketiva Streamster WSDL service API( A forex company). Read here more about it.


' To package SOAP request.
 Dim objSerial As MSSOAPLib.SoapSerializer

 ' To read SOAP response.
 Dim objRead As MSSOAPLib.SoapReader

 ' To connect to Web service using SOAP.
 Dim objConn As MSSOAPLib.SoapConnector

 ' To parse the SOAP response.
 Dim objResults As MSXML2.IXMLDOMNodeList
 Dim objNode As MSXML2.IXMLDOMNode

 ' Set up the SOAP connector.
 Set objConn = New MSSOAPLib.HttpConnector
 objConn.Property("EndPointURL") = "http://127.0.0.1:8018/endpoint"

 ' Define the SOAP action. You can find it in the WSDL's
 '  tag's soapAction attribute for the matching
 '  tag.

 objConn.Property("SoapAction") = "GetQuote"

 ' Begin the SOAP message.
 objConn.BeginMessage

 Set objSerial = New MSSOAPLib.SoapSerializer

 ' Initialize the serializer to the connector's input stream.
 objSerial.Init objConn.InputStream

 ' Build the SOAP message.
 With objSerial
 .startEnvelope ' 
 .startBody ' 

 .startElement "Instrument"
 .writeString "EUR/USD"
 .endElement ' input par

 .endBody ' 
 .endEnvelope ' 
 End With

 ' Send the SOAP message.
 objConn.EndMessage

 Set objRead = New MSSOAPLib.SoapReader

 ' Initialize the SOAP reader to the connector's output stream.
 objRead.Load objConn.OutputStream

 Debug.Print objRead.DOM.xml

 Set objResults = objRead.Body.childNodes

 For Each objNode In objResults

 Select Case objNode.nodeName
 Case "Quote"
 MsgBox objNode.selectSingleNode("Last").nodeTypedValue 'show Last price of quote
 MsgBox objNode.selectSingleNode("Time").nodeTypedValue 'show Time of quote
 Case Else
 End Select
 Next objNode

Searched By:

vb6 wsdl (13), MSSOAPLib (6), web reference visual basic 6 (3), powered by vBulletin reference (2), using web service vb6 marketiva (2), streamster c# sample (2), wsdl vb6 (2), streamster api indicator (1), vb6 api web reference (1), vb xml soap getquote (1), vb net soap xml wsdl mysql php (1), vb net 2010 service reference catch message (1), sopa vb6 response (1), vb dengan marketiva (1), vb 6 0 to read xml response from webservice (1), vb 6 0 read stream (1), vb 2010 post xml request (1), vb 2010 envelope (1), streamster api (1), using web references in vb6 (1)