我正在构建一个从对象中提取脚本的小应用程序。我已经到了我的代码从具有脚本的对象中拉回字段的部分,我收到了这个错误。
“对非共享成员的引用需要对象引用”
我不确定要改变什么或如何解决这个问题。有没有人有任何建议?
这是我到目前为止的代码。这是一个简单的应用程序,它有一个组合框,您可以从中选择公司,然后单击按钮,它将获取脚本并将其显示在文本框中。
这是我的代码:
Imports System.IO
Public Class Form1
Public M3System As MILLSYSTEMLib.System
Public M3Script As MILLCOMPANYLib.CScripting
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'On Error Resume Next
Try
Dim Approved As Integer
' Create a Millennium system obects
M3System = CreateObject("MillSystem.System")
M3System.Load("Millennium")
'run login script
Dim User As Object = M3System.Login()
' See if login worked
If User Is Nothing Then
'MsgBox("Login failed!")
Approved = 0
Else
'MsgBox("Login successful")
'if approved=1 then the user is able to access M3
Approved = 1
End If
'populate combo box
For Each Company In M3System.Companies
cb_COID.Items.Add(Company.Field("co").ToString)
Next
Catch ex As Exception
Me.Close()
End Try
End Sub
Public Sub btn_LoadScript_Click(sender As Object, e As EventArgs) Handles btn_LoadScript.Click
Dim CoCode As String = cb_COID.SelectedItem
Dim script As String = M3Script.vbscript
If IsNothing(cb_COID) Then
MessageBox.Show("Select a Company Code")
End If
For Each CoCode In M3Script.co
tb_Script.Text = script
Next
End Sub