|
-
Oct 24th, 2003, 10:13 AM
#1
Thread Starter
Addicted Member
two different objects, VB use just one
i have to object of the same type, but when i set a property of one of them, the VB puts the property on both.
Anybody knows why??
Thank you,
Guilherme Costa
-
Oct 24th, 2003, 10:16 AM
#2
Sounds like a they both reference the same object. Post some code or do a search for the difference between reference-type variables and value-type variables.
-
Oct 24th, 2003, 10:22 AM
#3
Thread Starter
Addicted Member
VB Code:
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
horario_ponta_ativo = False
ReDim gerador(2)
End Sub
Dim gerador() As ModbusOCX.Modbus_OCX
Private Sub Supervisório_Terra_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To 1
gerador(i) = New ModbusOCX.Modbus_OCX
Next
gerador(0).config_Porta = ModbusOCX.Modbus_OCX.ValoresPorta.COM3
gerador(0).abre_porta()
gerador(1).config_Porta = ModbusOCX.Modbus_OCX.ValoresPorta.COM4
gerador(1).abre_porta()
relogio.Start()
gerador_ponta.Start()
End Sub
i hope that this could help you to help me!!!
Guilherme Costa
-
Oct 24th, 2003, 10:41 AM
#4
Huh I'm not sure you set them both to new objects in your loop so it should be fine. So you are saying that gerador(0).config_Porta equals ModbusOCX.Modbus_OCX.ValoresPorta.COM4 instead of COM3? Is that how are you testing that they are set to the samething? This could be an issue with this particular object? Is it derived from an OCX or ActiveX object (hence the OCX in the name)?
-
Oct 24th, 2003, 11:20 AM
#5
Thread Starter
Addicted Member
yeah, this project i have upgraded from VB6, but i use it in my application like gerador1 and gerador2 now, and it worked fine!
maybe it get lost because i was trying to use as array or something!
Thanks for your help!!
Guilherme Costa
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|