Latest News

the latest news from our team

MPE File Access – Access from VB

The MDMDA session

The MDMDA session object is being called from a Visual Basic application.

Download sample code [FTP] [HTTP]

Option Explicit

Dim DA As Object
Dim FMPE As Object

Private Sub Form_Load()

Dim Password As String
Dim fopt
Dim aopt

Set DA = CreateObject("MdmDA.Session")
DA.HostAddress = "support.minisoft.com"
DA.Port = 30002
DA.LoginUser = "MGR"
DA.LoginAccount = "MINISOFT"
DA.UserPassword = InputBox("User Password")
DA.TraceFile = "TEST.LOG"
DA.TimeOut = 10
DA.TraceLevel = 15
DA.Connect

fopt = &O4
aopt = &O4

If DA.ConnectStatus = True Then

Set FMPE = DA.AddMPEFileRef("ACMD1NEW")
FMPE.Delimiter = ","
If FMPE.FOpen("ACMD1NEW", fopt, aopt, 80, 0) Then
FMPE.AddItem "REC1", "X", 80, 0, 1, False, True
Else
MsgBox FMPE.ErrorMessage, vbCritical, "FOpen"
End If

End If

WriteRec_Click
ErrorMessage = FMPE.ErrorMessage
ErrorNumber = FMPE.ErrorNumber

End Sub

Private Sub Form_Unload(Cancel As Integer)

Set FMPE = Nothing
DA.Disconnect

Set DA = Nothing
End

End Sub

Private Sub ReadRec_Click()

Rec1.Text = ""
If FMPE.FRead(80) Then
Rec1.Text = FMPE.Item("REC1")
Else
If (FMPE.ErrorNumber <> 0) Then
MsgBox FMPE.ErrorMessage
MsgBox FMPE.ErrorNumber
End If
End If
ErrorMessage = FMPE.ErrorMessage
ErrorNumber = FMPE.ErrorNumber

End Sub

Private Sub RewindCmd_Click()

If FMPE.FPoint(0) Then
Else
MsgBox FMPE.ErrorMessage
MsgBox FMPE.ErrorNumber
End If
ErrorMessage = FMPE.ErrorMessage
ErrorNumber = FMPE.ErrorNumber

End Sub

Private Sub WriteRec_Click()

FMPE.Item("REC1") = "test" + Format(Rnd(500))
If FMPE.FWrite(80) Then
Else
MsgBox FMPE.ErrorMessage
MsgBox FMPE.ErrorNumber
End If
ErrorMessage = FMPE.ErrorMessage
ErrorNumber = FMPE.ErrorNumber

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *