-3
已经宣布在Form2的变量这是我的表格1我想用我在Form1中
Public Class Form1
Dim excelapp As Microsoft.Office.Interop.Excel.Application
Dim excelwb As Microsoft.Office.Interop.Excel.Workbook
Dim excelws As Microsoft.Office.Interop.Excel.Worksheet
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Calling form for New
Dim new1 As New Form2
new1.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'To Open File
Using FileDialog As New OpenFileDialog
FileDialog.Title = "Select your Excel file"
FileDialog.Filter = "Microsoft Excel|*.xl*|All Files|*.*"
FileDialog.ShowDialog()
Process.Start(FileDialog.FileName)
Dim s As String = FileDialog.FileName
excelwb = excelapp.Workbooks.Open(FileDialog.FileName)
excelws = excelwb.Worksheets(1)
'End Using
' Using FileProcess As Process = Process.Start(FileDialog.FileName)
End Using
'Calling form for Open
Dim new1 As New Form2
new1.Show()
这是我的表2
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'New Entry in existing excel file
excelws.Cells(3, 1).Value = TextBox1.Text
excelws.Cells(3, 2).Value = TextBox2.Text
excelws.Save()
End Sub
我想用所有的变量和所有的form2中form1的东西。 请帮助我如何在我的表单2中使用这些东西。 我正在准备一个应用程序来接受用户输入并为其生成pdf。 即时通讯使用Excel保存数据和VB Express 2010创建窗体。 请指导我:)非常感谢。
在functions/subs之外声明它们为PUBLIC。 – FDavidov
你能帮我解码吗?我有点新。如果我宣布它们是公开的,我应该如何以form2形式提及这些公共数据? –
我没有看到第一种形式的任何变量;声明,“提及”或以其他方式 – Plutonix