Home > Software engineering >  In VB6.0 by use of how a form pops up another form, and then returns a value of another form
In VB6.0 by use of how a form pops up another form, and then returns a value of another form

Time:10-04

So I have a form 1, click on one of the button pop-up window 2.

Form 2 a listview, I chose one of the few lines, and save the results into a public variable,

Now I want to be in the form of 2 closed, will the results back to the form of the common variables 1 textbox1.

But I found that I always textbox1. Text=bomstr FrmBomList again. Show,
The textbox1 text is always empty, how to get to the values in the form 2 (bomstr)? Or am I wrong?
 

Private Sub getBomInfo ()
Dim bomlist As FrmBomList
FrmBomList. Show
Textbox1. Text=bomstr
END SUB


The form 2
 
Public bomstr As String
Private Sub Command2_Click ()
Bomstr=""

If ListView1. ListItems. Count & lt; 1 Then
Dim As Integer I
I=MsgBox (" the Part no information, please confirm, 16, "tip") 'message box tip
The Else
Dim PartInfo As String
PartInfo=""
For I=0 To ListView1. ListItems. Count - 1
'If ListView1. ListItems (I + 1) Checked=True Then
If ListView1. ListItems. Item (I + 1) Checked=True Then
PartInfo=PartInfo + CStr (ListView1 ListItems (I + 1). SubItems (1)) + ", "' I + 1 to define the number of rows
End the If
'I=I + 1
Next
If Len (PartInfo) & gt;=1 Then
Text1. Text=Mid (PartInfo, 1, Len (PartInfo) - 1)
Bomstr=Text1. Text
End the If
End the If
End Sub

CodePudding user response:

FrmBomList. Show 1

CodePudding user response:

Thank the great god reply upstairs, I also tried this method, which is ascribed value, then frm2 pop-up, select data in FRM or affect frm1 results

CodePudding user response:

You build a moudle, built a global variable

CodePudding user response:

I'm sorry, write wrong, is to create a module

CodePudding user response:

Add a form1 in Form2. Text1. Text=bomstr

CodePudding user response:

In From2 command2 event finally add a: From1, Text1. Text=bomstr should be ok

CodePudding user response:

http://zhidao.baidu.com/question/140287908.html

http://zhidao.baidu.com/question/55286693.html

http://zhidao.baidu.com/question/96503971.html

CodePudding user response:

refer to 7th floor caozhy response:

http://zhidao.baidu.com/question/140287908.html
http://zhidao.baidu.com/question/55286693.html

http://zhidao.baidu.com/question/96503971.html


Thank moderator hand eager to help, but the question I may have some different, so, I have two pieces of code actually kingdee K3 secondary development in east, this window is to actually call out on a control, so can't use 1, show me this, but if not, he will direct execution of the first show at the back of the code, then pop up I need to show the FRM...

CodePudding user response:

 'Form1 
Option Explicit

Public Property Let bomstr (ByVal RHS As String)
Textbox1. Text=RHS
End Property

Private Sub getBomInfo ()
FrmBomList. Action Me
End Sub

 'FrmBomList 
Option Explicit

Private m_OwnerForm As Form1

Public Sub Action (ByVal OwnerForm As Form1)
The Set m_OwnerForm=OwnerForm
M_OwnerForm. Bomstr=""
Me. Show, OwnerForm
End Sub

Private Sub Command2_Click ()
If ListView1. ListItems. Count & lt; 1 Then
Dim As Integer I
I=MsgBox (" the Part no information, please confirm, 16, "tip") 'message box tip'
The Else
Dim PartInfo As String
PartInfo=""
For I=0 To ListView1. ListItems. Count - 1
'If ListView1. ListItems (I + 1) Checked=True Then
If ListView1. ListItems. Item (I + 1) Checked=True Then
PartInfo=PartInfo + CStr (ListView1 ListItems (I + 1). SubItems (1)) + ", "' I + 1 to define the number of rows
End the If
'I=I + 1
Next
If Len (PartInfo) & gt;=1 Then
Text1. Text=Mid (PartInfo, 1, Len (PartInfo) - 1)
M_OwnerForm. Bomstr=Text1. Text
End the If
End the If
End Sub

Private Sub Form_Unload (Cancel As Integer)
The Set m_OwnerForm=Nothing
End Sub

CodePudding user response:



Form1
 
Private Sub Command1_Click ()
Form2. Show 1
End Sub


 
Private Sub Command1_Click ()
'strSelectedName=""

If ListView1. ListItems. Count & lt; 1 Then
Dim As Integer I
I=MsgBox (" the Part no information, please confirm, 16, "tip") 'message box tip
The Else
Dim PartInfo As String
PartInfo=""
For I=0 To ListView1. ListItems. Count - 1
'If ListView1. ListItems (I + 1) Checked=True Then
If ListView1. ListItems. Item (I + 1) Checked=True Then
'PartInfo=PartInfo + CStr (ListView1 ListItems (I + 1). SubItems (1)) + ", "' I + 1 to define the number of rows
PartInfo=PartInfo + ListView1. ListItems (I + 1). The Text + ", "
End the If
'I=I + 1
Next
If Len (PartInfo) & gt;=1 Then
'Text1. Text=Mid (PartInfo, 1, Len (PartInfo) - 1)
'bomstr=Text1. Text
Form1. Text1. Text=PartInfo
End the If
End the If

Unload Me

End Sub

Private Sub Form_Load ()
For I=1 To 10
Me. ListView1. ListItems. Add I, "A" + CStr (I), "the Boss" + CStr (I)
Next I
End Sub
nullnullnullnullnullnullnullnullnullnullnull
  • Related