Sub CommandButton1_Click()
Dim DataObj As MSForms.DataObject
'----Ham nay lay data tu Clipboard
Dim MyString As Variant
Dim MyS As String
Dim x As Integer, i As Integer
Dim text As String, Editext As String
Dim icount As Long
Dim n As Integer
Dim ar As Variant
Dim Ghep As String
Set DataObj = New MSForms.DataObject
On Error GoTo Whoa
DataObj.GetFromClipboard
MyString = DataObj.GetText(1)
MsgBox MyString
[I21] = MyString
'-- khong co du lieu vao day
Whoa:
If Err <> 0 Then MsgBox "Khong co du lieu trong Clipboard"
text = Trim([I21]) '(( neu la mot [321 3213 3213 3213 3213] thi hame chay tot
' dem chuoi
' lan sau dung Funtion WorkSheetFuntion SubTitute // ham excel
x = DemKT(text) + 1 ' dem so khoang trang
Debug.Print x
On Error Resume Next
For i = 1 To 1
ar = Split(text, " ", x)
TextBox1 = ar(0)
TextBox2 = ar(1)
TextBox3 = ar(2)
TextBox4 = ar(3)
TextBox5 = ar(4)
TextBox6 = ar(5)
Next
On Error GoTo 0
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub CommandButton3_Click()
End Sub
Function DemKT(Chuoi As String) As Long
Trim (Chuoi)
DemKT = Len(Chuoi) - Len(Replace(Chuoi, " ", ""))
End Function
Function JoinText(Vung As Range, Optional PC As String = ", ") As String
On Error GoTo Tiep1
With Application.WorksheetFunction
JoinText = Join(.Transpose(Vung), Chr(13))
GoTo Tiep2
Tiep1:
JoinText = Join(.Transpose(.Transpose(Vung)), Chr(13))
End With
Tiep2:
JoinText = Replace(JoinText, " ", Chr(10))
JoinText = Replace(JoinText, Chr(13), " ")
JoinText = WorksheetFunction.Trim(JoinText)
JoinText = Replace(JoinText, " ", PC)
JoinText = Replace(JoinText, Chr(10), " ")
End Function
Private Sub UserForm_Click()
End Sub