接口rs232与visual basic 6.0 ... [英] interface rs232 with visual basic 6.0...

查看:57
本文介绍了接口rs232与visual basic 6.0 ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我得到了接口并行端口到视觉的编码...但是使用这个编码我想修改哪个地址应该编辑这个编码,以便可以连接两个...实际上我做的项目在红绿灯处可以检测到故障
指示..使用ATmega32并与rs232接口...可以任何人帮助我...









私有声明函数Inp32 Lib"Dllport.dll" (ByVal PortAddress As Integer)As Integer


Private Declare Sub Out32 Lib" Dllport.dll" (ByVal PortAddress As Integer,ByVal Value As Integer)


Dim Mydate As Date


< p style =""> 


私有子Command1_click() '停止按钮


Timer1.Interval = 0 '程序运行的计时器


Timer2.Interval = 0 '日期运行的计时器


结束Sub


 


私有Sub Command2_click() '运行按钮


Timer1.Interval = 500


Timer2.Interval = 100


结束Sub


 


私有子Command3_Click() '取消按钮


卸载我


Form4.Show


结束次级


 


私人子Timer1_Timer()


'阅读输入


Label1.Caption =(Inp32(& H379))和8 'red


Label2.Caption =(Inp32( & H379))和16 'orange


Label3.Caption =(Inp32(& H379))和32
'green


Label4.Caption =(Inp32(& H379))和64
'fault1


   


 


如果是Label1。 Caption = 8然后 '红灯


Shape2.Visible = True


Shape1.Visible = False


< p style =""> Label11.Caption =" OK"


ElseIf Label1.Caption = 0然后


Shape2.Visible = False


< p style =""> Shape1.Visible = True


Label11.Caption =" ERROR"


哔声


结束


 


如果Label2.Caption = 16那么 '橙色光


Shape4.Visible = True


Shape3.Visible = False


Label16.Caption =" OK" ;


ElseIf Label2.Caption = 0然后


Shape4.Visible = False


Shape3.Visible = True


Label16.Caption =" ERROR"


哔哔


< p style =""> 结束如果


 


如果Label3.Caption = 32那么 '绿灯


Shape6.Visible = True


Shape5.Visible = False


Label17.Caption =" OK"


ElseIf Label3.Caption = 0然后


Shape6.Visible = False


Shape5.Visible = True


Label17.Caption =" ERROR"


< p style =""> 哔哔


如果结束


 


如果Label4.Caption = 64那么'the fault 1


Label10.Caption =" OK"


ElseIf Label4.Caption = 0然后


Label10.Caption =" ERROR"


< p style =""> 哔哔


如果结束


 


 


'将输入发送到输出数据行


如果Label1.Caption = 8则Out32& H378,1'红灯输出


如果是Label2。 Caption = 16然后Out32& H378,2'橙色光的输出


如果Label3.Caption = 32那么Out32& H378, 4'绿灯输出


如果Label4.Caption = 64那么Out32& H378,8'输出故障1


 


结束次


 


私人子Timer2_Timer()


Label7.Caption =日期'系统日期


Label8 .Caption =时间'系统日期


Mydate =格式(Label7.Caption ,"D - MMMM - YY")
'系统日期


Label9.Caption =格式(Mydate," dddd")


 


结束次


< p style =""> 


私有子Form_Load()'设置交通灯的开头软件


Shape1.Visible = False


Shape3.Visible = False


Shape5.Visible = False


< p style =""> Shape2.Visible = True


Shape4.Visible = True


Shape6.Visible = True


结束次


解决方案

请阅读


http://social.msdn.microsoft.com/Forums/is/vblanguage/thread/aa350a38-3bb9-4919-9cc1-afaf7fed52f5


 


这些论坛是针对VB.NET问题而不是VB6。


因此该链接具有可用于VB6的资源,或者您可以下载VB Express并开始编写VB.NET代码。


here i got the coding for interface parallel port to visual...but with using this coding i would like to modify the which address should edit inthis coding so that can be connected both...actually im doing project in traffic light which can detect the fault indicator..im using ATmega32 and interface with rs232..could anybody help me...

Option Explicit 'Declaration on all the input and output file

Private Declare Function Inp32 Lib "Dllport.dll" (ByVal PortAddress As Integer) As Integer

Private Declare Sub Out32 Lib "Dllport.dll" (ByVal PortAddress As Integer, ByVal Value As Integer)

Dim Mydate As Date

 

Private Sub Command1_click() 'Stop button

Timer1.Interval = 0 'the timer for the program run

Timer2.Interval = 0 'the timer for the date run

End Sub

 

Private Sub Command2_click() 'Run button

Timer1.Interval = 500

Timer2.Interval = 100

End Sub

 

Private Sub Command3_Click() 'Cancel button

Unload Me

Form4.Show

End Sub

 

Private Sub Timer1_Timer()

'Reading input

Label1.Caption = (Inp32(&H379)) And 8 'red

Label2.Caption = (Inp32(&H379)) And 16 'orange

Label3.Caption = (Inp32(&H379)) And 32 'green

Label4.Caption = (Inp32(&H379)) And 64 'fault1

   

 

If Label1.Caption = 8 Then 'the red light

Shape2.Visible = True

Shape1.Visible = False

Label11.Caption = "OK"

ElseIf Label1.Caption = 0 Then

Shape2.Visible = False

Shape1.Visible = True

Label11.Caption = "ERROR"

Beep

End If

 

If Label2.Caption = 16 Then 'the orange light

Shape4.Visible = True

Shape3.Visible = False

Label16.Caption = "OK"

ElseIf Label2.Caption = 0 Then

Shape4.Visible = False

Shape3.Visible = True

Label16.Caption = "ERROR"

Beep

End If

 

If Label3.Caption = 32 Then 'the green light

Shape6.Visible = True

Shape5.Visible = False

Label17.Caption = "OK"

ElseIf Label3.Caption = 0 Then

Shape6.Visible = False

Shape5.Visible = True

Label17.Caption = "ERROR"

Beep

End If

 

If Label4.Caption = 64 Then 'the fault 1

Label10.Caption = "OK"

ElseIf Label4.Caption = 0 Then

Label10.Caption = "ERROR"

Beep

End If

 

 

'Send the input to output data line

If Label1.Caption = 8 Then Out32 &H378, 1 'the output of red light

If Label2.Caption = 16 Then Out32 &H378, 2 'the output of orange light

If Label3.Caption = 32 Then Out32 &H378, 4 'the output of green light

If Label4.Caption = 64 Then Out32 &H378, 8 'the output of fault 1

 

End Sub

 

Private Sub Timer2_Timer()

Label7.Caption = Date 'system date

Label8.Caption = Time 'system date

Mydate = Format(Label7.Caption, "D - MMMM - YY") 'system date

Label9.Caption = Format(Mydate, "dddd")

 

End Sub

 

Private Sub Form_Load() ' Set the traffic light at the start of the software

Shape1.Visible = False

Shape3.Visible = False

Shape5.Visible = False

Shape2.Visible = True

Shape4.Visible = True

Shape6.Visible = True

End Sub

解决方案

Please Read

http://social.msdn.microsoft.com/Forums/is/vblanguage/thread/aa350a38-3bb9-4919-9cc1-afaf7fed52f5

 

These forums are for VB.NET questions and not VB6.

So the link has resources that you can use for VB6 or you could download VB Express and start writing VB.NET code.


这篇关于接口rs232与visual basic 6.0 ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆