vb提取LIST中的数字 30
vb提取LIST中的数字并且相加。LIST中有很多行如第一行为ABC123,第二行为BCD456第3行为谢谢567直到N行现想提取每行的数字字母活中文不要并且相加其中的数...
vb提取LIST中的数字并且相加。LIST中有很多行 如第一行为ABC123 ,第二行为BCD456 第3 行为 谢谢567 直到N行 现想提取 每行的数字字母活中文不要并且相加其中的数字 该怎么写代码 谢了
并且能把LEST 内容保存在指定EXCEL 中且新内容不会覆盖以前内容, 展开
并且能把LEST 内容保存在指定EXCEL 中且新内容不会覆盖以前内容, 展开
展开全部
Private Sub Command1_Click()
Dim i As Integer, N As Integer, NM As Integer
For i = 0 To List1.ListCount - 1
N = StrReverse(Val(StrReverse(List1.List(i))))
Debug.Print N
NM = NM + N
Next
MsgBox NM
End Sub
Private Sub Form_Load()
List1.AddItem "ABC123"
List1.AddItem "雀贺BCD456"
List1.AddItem "顷备派谢谢567"滚则
End Sub
Dim i As Integer, N As Integer, NM As Integer
For i = 0 To List1.ListCount - 1
N = StrReverse(Val(StrReverse(List1.List(i))))
Debug.Print N
NM = NM + N
Next
MsgBox NM
End Sub
Private Sub Form_Load()
List1.AddItem "ABC123"
List1.AddItem "雀贺BCD456"
List1.AddItem "顷备派谢谢567"滚则
End Sub
追问
你是我偶像,可否帮我写2第二个问题
追答
Private Sub Command1_Click()
Dim objApp As Object
Dim objWorkbook As Object
Dim objWorksheet As Object
Dim objRange As Object
Dim CellsData()
Dim i As Long, nRows As Long
ReDim CellsData(List1.ListCount - 1)
For i = 0 To List1.ListCount - 1
CellsData(i) = List1.List(i)
Next
Set objApp = CreateObject("Excel.Application")
objApp.ScreenUpdating = False
Set objWorkbook = objApp.Workbooks.Open("c:\1.xls")
Set objWorksheet = objWorkbook.Sheets("sheet1")
nRows = objWorksheet.Range("a65536").End(-4162).Row
If nRows > 1 Then nRows = nRows + 1
Set objRange = objWorksheet.Range("a" & (nRows), "a" & (nRows + List1.ListCount) - 1)
objRange.Value = objApp.Transpose(CellsData)
objWorkbook.SaveAs "c:\1.xls" '保存到指定文件
objWorkbook.Close
objApp.Quit
Set objRange = Nothing
Set objWorksheet = Nothing
Set objWorkbook = Nothing
Set objApp = Nothing
Erase CellsData
End Sub
Private Sub Form_Load()
List1.AddItem "ABC123"
List1.AddItem "BCD456"
List1.AddItem "谢谢567"
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询