CodePudding user response:
Remember to Excel itself to support to do so, don't write any code,CodePudding user response:
Here to learn two things:Write 1 input interface,
2 write Excel table,
Input interface operation is based on event trigger:
Private Sub Text1_KeyPress (KeyAscii As Integer)
The Select Case KeyAscii
Case 8, Asc (" 0 ") To Asc (" 9 ") limit can be input character '
Case 13
If Text1 & gt; "" Then" enter processing
Text2=""
Text2. SetFocus
End the If
In Case the Else
KeyAscii=0
End the Select
End Sub
Private Sub Text2_KeyPress (KeyAscii As Integer)
The Select Case KeyAscii
Case 8, Asc (". "), Asc (" 0 ") To Asc (" 9 ")
Case 13
If Text2 & gt; "" Then
'save here to write to Excel code
'here to prepare the next entry
Text1. SelStart=0
Text1. SelLength=Len (Text1)
Text1. SetFocus
End the If
In Case the Else
KeyAscii=0
End the Select
End Sub
Save to Excel there are two main methods:
1 USES VB Excel object, written by cell, or will be vbTab separated columns, vbCrLf dividing lines of the string to add to the Range object,
2 will Excel as a Jet Engine external database, through ADO or DAO object, writing new record, can adopt the recordset AddNew way, also can use SQL Insert statements side
Type,
The above content can search on the Internet, there are a lot of examples,
CodePudding user response:
Reference