Hello everyone, again me, with new project. Just to remind you, I am still in Gymnasium and I learn everything by my self so please explain any possible solution as much as you can. Thanks
So here is the thing, I imported some (random) Excell file in VB and imported specific Cell in Textbox. Now I want to split one Textbox in two or more Textboxes. Example:
But the thing is I have to do this for at least 44 Cells and for up to 6 names so it would be preety hard and long to write this kind of code for all Cells. So I have an idea how to make it short and simple:
Code:
Private Function Separate(ByVal x As Integer, ByVal y As String) As String
While a > n
textbox(n+1).text = textbox(n).text.Substring(textbox(n).text.IndexOf("/>"))
textbox(n).text = textbox(n).text.replace(textbox(n+1),"")
textbox(n).text = textbox(n).text.replace("<br ","")
textbox(n+1).text = textbox(n+1).text.Sunbstring(2)
n=n+1
Dim stgSearch As String
Dim stgCount() As String
Dim a, n As Integer
TextBox1.Text = ws.Cells(6, 6).value
n=1
stgSearch = Textbox1.text
stgCount = Split(stgSearch, "<br" , -1)
a = UBound(stgCount) + n
Call Separate
Textbox7.Text = ws.Cells(11,6).value
n=7
stgSearch = Textbox7.text
stgCount = Split(stgSearch, "<br" , -1)
a = UBound(stgCount) + n
Call Separate
And so on (reason why I made n = 7 is to "book" 6 labels for first Cell), for as many Cells I need. The problem is that textbox(n).text and textbox(n+1).text doesn't work for me, so anyone can help me out here?
Thanks alot! Bezzi94
p.s.: I apologise for possible grammar and code mistakes
Try recording a Macro, to do everything EXCEPT the split, and work for ALL the rows, you can edit that code to add the SPLIT in the right place. (It should create a loop, or something you can convert INTO a loop.
Edit: Also, use [Resolved] in the title only to tell us that you do not need any more help for the thread... It's like CLOSING it]
Last edited by dglienna; February 5th, 2013 at 05:25 PM.
Bookmarks