How to insert text in between texts in Textbox VB6/VBA -


i wanted insert texts(new line) in between existing texts in textbox (multiline = true).


example: (textbox1.text's value written below)

name: name of client

dob: 11/11/11

>>>this insert value of textbox2.text

hospitalization: no

serial number: 12345678


private sub cmdtransfer_click()    dim searchnote integer, searchthis string, tx2 string     if cb9.value = true         tx2 = "address: " & vbtab & text2.text & vbcrlf    end if     searchthis = "hospitalization"    searchnote = instr(textbox1.text, searchthis)     if searchnote        textbox1           .setfocus           .selstart = searchnote           .text = .text & .selstart & tx2        end    end if  end sub 

what i'm doing in code i'm getting number of characters before "hospitalization" can insert value of textbox2 before it. dont know how tho. please help.

thanks!

i believe code looking this:

left(searchnote, instr(1, searchnote, "hospitalization") - 1) & "new text insert" & mid(searchnote, instr(1, searchnote, "hospitalization")) 

left take first few letters starting point of "hospitalization". insert new string (possible new line before , after & chr(10) &). add mid after "hospitalization".


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -