VB6 Global string array declaration in ActiveX control and Package installation error
Hi friends, I have been working on an activeX control which works on serial port communication. Now I have completed the project and created its setup.exe using Visual studio 6 -> Tools -> Package and Deployment Wizard. Then I installed the control in another PC and in a new project included the control using project -> components. But when I click on the control in the toolbox and then include on the form it gives the following error : delete current link ? and on clicking OK, nothing happens. I tried searching a lot on google but didnt find anything. Another problem is that I have created a string array as a global array which can be accessed by all the methods.I am able to include the same activex control in my own pc when I have created the project. Here it works fine, I am able to access all the methods that I coded in the control, but the String array mentioned above can be accessed in other project. I tried writing Public before the array declaration but it give me the compile error : "Constants. fixed length strings, arrays, user defined types and Declare statements not allowed as Public members of object module."
I am posting the code below so you all can understand what m I trying to say. Plz help me guys if u have a solution to these two problems. thanks.
Option Explicit
Dim ReplyMessageArray() As String 'this the array i m not able to access in another project
Public Sub FillStringArray(ReplyString As String) ' the array is filled in this method
Dim i As Integer
If flg = False Then
ReDim ReplyMessageArray(0 To 0) As String
flg = True
Else
ReDim Preserve ReplyMessageArray(0 To UBound(ReplyMessageArray) + 1) As String
End If
ReplyMessageArray(UBound(ReplyMessageArray)) = ReplyString
End Sub
Re: VB6 Global string array declaration in ActiveX control and Package installation e
Try doing something like this:
Code:
'user control code:
Option Explicit
Dim arTest() As String
Private Sub UserControl_Initialize()
ReDim arTest(0)
arTest(0) = "initial value"
End Sub
Private Sub AddNewValue(new_value As String)
If Not arTest(0) = "initial value" Then
ReDim Preserve arTest(UBound(arTest) + 1)
End If
arTest(UBound(arTest)) = new_value
End Sub
'for convenience of testing I populate array here
Private Sub Command1_Click()
AddNewValue Text1.Text
End Sub
Public Function getArray() As String()
getArray = arTest()
End Function
'====================================
'main form code:
Private Sub Command1_Click()
Dim i As Integer
Dim arTest() As String
arTest = myControl.getArray()
For i = 0 To UBound(arTest)
Debug.Print arTest(i)
Next i
End Sub
Re: VB6 Global string array declaration in ActiveX control and Package installation e
thanks a lot RhinoBull..the string array is accessible now...so any help on after the package installation and using the control in another PC the error appearing is : "Delete Current Link ?"
Re: VB6 Global string array declaration in ActiveX control and Package installation e
I don't understand what the problem is. Perhaps you can explain it better.
Btw, your original post is quite difficult to read - it's like one very large sentence.
Try making paragraph, separating one question from another, wrap your code with [CODE tags, etc...] to make it more redable.