zhujp98
09-07-2003, 09:24 PM
I have an application:
Private Sub mndOk_Click()
frmRecords.Show
frmRecords.txtRecords.Text = frmRecords.txtRecords.Text _
& Chr$(10) & txtFishSize.Text
SetFocus
End Sub
txtFishSize is an txt field, Ok is a button txtRecords is another field in another form frmRecords
What i am trying to is: the records which user input in txtFishSize will go to txtRecords in different line.like
record 1
record 2
record 3
not record 1 record 2 record 3
But the above code does not work
How can i fix the problem?
Any suggestion will be appreciated.
J.P.
Squishy
09-07-2003, 09:26 PM
Try using vbCrLf instead, which is both Chr(13) and Chr(10). What does the SetFocus do?
zhujp98
09-07-2003, 09:41 PM
Thanks for reply
after i make change according to your instruction, the records appeared in txtRecords still in same line,
It looks like
|| record 1 || record 2 || record 3 || record 4
(|| is very similar to the symbol in the txtRecords but it is thicker there)
but if i copy it to a text editor all record will appear in different lines.
how can i fix this problem?
Thanks
Squishy
09-07-2003, 09:42 PM
Set the textbox's MultiLine property to True.
codemib
09-08-2003, 12:04 AM
what Photovoltaic said is right
First: You must set your txtRecords "MultiLine" property to "True" then you can use "vbCrLf" in your code to create newline
Second: You should always use GLOBAL MODULE to hold global variable(s) for multiple forms. In your case, I think it is better to use a concanate string to display the values into frmRecords.txtRecords.text
Click Project-> Add Module Then give it a named whatever you wish, default is "Module1". it is saved as "Module1.bas"
Third: declare a string or integer variable in "Module1"
public gintValue as Integer 'use as integer
public gstrValue as String 'use as string
then try this code below:
Private Sub mndOk_Click()
If txtRecords.Text = "" Then 'if the textbox is empty
Msgbox "Enter Value",VbOkonly + VbExclamation, "Empty"
txtRecords.SetFocus 'set focus
ElseIf Isnumeric(txtRecords.text)Then 'if the value in the textbox is numeric
gintValue = val(txtRecords.text)
With frmRecords
.txtRecords.Text = gintValue
.Show 'show 0 or 1 is up to you
End With
Else 'If the value in the text box is not numeric
Msgbox "Enter Number Only",VbOkonly + VbExclamation,"Invalid Entry"
txtRecords.setFocus
End If
End Sub
If you display more than 1 integers value in frmRecords.txtRecords.text then it is better to use a concanate string:
gstrValue = Val(txtRecords1.text) & vbCrlf & Val(txtRecords2.Text) & vbcrlf & Val(txtRecords3.Text)
'then display all 3 values in the frmRecords Form
frmRecords.txtRecords.Text = gstrValue
There you go....you can have multiline values
value1
value2
value3;
.
.
.