inpout32 run well in c# but problem in vb6

My x64 port of InpOut32
Post Reply
MCHOUD
New User
Posts: 2
Joined: Sat Jun 20, 2009 7:24 am

inpout32 run well in c# but problem in vb6

Post by MCHOUD » Sat Jun 20, 2009 7:39 am

Dear All

I got a program which is utilizing inpout32 developed with c#, unfortunately the developer has gone. Now i want to continuing the programming with vb6. This inpout32 is controlling 3 unit of seven segmen digital display box, every box is having 3 characters.

Display box whill showing the number which is send from database, for example, box one displaying 123, box2 is displaying 221, box3 displaying 331. There is no problem while using C#, when i trying to developing vb6, the display could not showing what we have sent.

The following is the right code of C#


class LPT
{
// Call OutPut function from DLL file.
[DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int adress, int value);

// Call Input functionfrom DLL file
[DllImport("inpout32.dll", EntryPoint = "Inp32")]
public static extern int Input(int adress);



}


private void ShowNumber(string nomor, int iloket)

{
string satuan;
string puluhan;
string ratusan;

try
{
satuan = nomor.Substring(nomor.Length - 1, 1);
puluhan = nomor.Substring(nomor.Length - 2, 1);
ratusan = nomor.Substring(nomor.Length - 3, 1);

LPTCall(int.Parse(satuan));
LPTCall(int.Parse(puluhan));
LPTCall(int.Parse(ratusan));
LPTCall(iloket);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}

}


private void LPTCall(int angka)
{
try
{
LPT.Output(888, angka);
LPT.Output(888, angka + 128);
System.Threading.Thread.Sleep(50);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}


And the following is my not working vb6 codes, what s wrong with this
Private Sub Command3_Click()
Dim sat, pul, rat, loket As Integer
sat = 1
pul = 2
rat = 3
loket = 1

Out 888, sat 'perintah ini sama dengan out val("&H"+"378"),sat
fctPause (10)
Out 888, sat + 128
fctPause (10)
Out 888, pul
fctPause (10)
Out 888, pul + 128
fctPause (10)
Out 888, rat
fctPause (10)
Out 888, rat + 128
fctPause (10)
Out 888, loket
fctPause (10)
Out 888, loket + 128
fctPause (10)
Out 888, 0
fctPause (10)
Out 888, 0 + 128
fctPause (10)
Out 888, 255
fctPause (400)
End Sub

Thanks for any kind helps
Kholid

User avatar
phil
Site Admin
Posts: 5958
Joined: Sun Apr 06, 2003 11:12 pm

Re: inpout32 run well in c# but problem in vb6

Post by phil » Sat Jun 20, 2009 6:04 pm

Why on earth would you take a program written in a nice modern language such as C# and want to port it to the ancient VB6??! VB.Net I could understand maybe!

I'm not an expert with VB6 but how have you mapped Out to the InpOut DLL funcitons? Can you show me where you are calling the DLL functions?

There are examples of using InpOut in VB6, if not on my website. They should provide more than enough detail to get you going with this.

Let me know if you cant find the info you are looking for there and I will try and dig it out for you.

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

MCHOUD
New User
Posts: 2
Joined: Sat Jun 20, 2009 7:24 am

Re: inpout32 run well in c# but problem in vb6

Post by MCHOUD » Tue Jun 23, 2009 10:05 am

This is my inpout declaration

Declare sub Output Lib "inpout32.dll" Alias "Out32" (ByVal address as long, ByVal value as long)

Declare function Input lib "inpout32.dll" Alias "Inp32" (Byval address as long) as long

User avatar
phil
Site Admin
Posts: 5958
Joined: Sun Apr 06, 2003 11:12 pm

Re: inpout32 run well in c# but problem in vb6

Post by phil » Tue Jun 23, 2009 9:22 pm

OK, maybe that is your problem then....

You have declared the functions as Output and Input but your code appears to be calling Out and not Output?

Try this instead....

Code: Select all

Private Sub Command3_Click()
Dim sat, pul, rat, loket As Integer
sat = 1
pul = 2
rat = 3
loket = 1

Output 888, sat 'perintah ini sama dengan out val("&H"+"378"),sat
fctPause (10)
Output 888, sat + 128
fctPause (10)
Output 888, pul
fctPause (10)
Output 888, pul + 128
fctPause (10)
Output 888, rat
fctPause (10)
Output 888, rat + 128
fctPause (10)
Output 888, loket
fctPause (10)
Output 888, loket + 128
fctPause (10)
Output 888, 0
fctPause (10)
Output 888, 0 + 128
fctPause (10)
Output 888, 255
fctPause (400)
End Sub
???

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9, Logitech MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, Intel i5-9600k, Asus Z390-ROG, 16GB DDR4,
nVidia GeForce GTX 970, Evo 970 500Gb NVME, 2x2TB WD Black (RAID1)

Post Reply