Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Question, Seltext And Savefile


hello , i have a working code that worked fine until we installed some service packs for windows 2000 pro . this is my issue ...

as400.SelText = sendq8.Text    (this line of code suppose to copy the text to another text box...im sure everyone here knows that

the data looks like this ...

TEST1
TEST2
TEST3
TEST3

When i do ...

as400.SaveFile "c:LOGSas400q.log", rtfText

the file looks the same as above . but after the SP's were installed , the saved file now looks like this ...

TEST1    TEST2    TEST3    TEST4

The code hasnt changed since 2001 .. not sure whats causing the saved file to be formatted differently. If i open the file in WORDPAD its perfect but in NOTEPAD its wrong.
I feel like the answer to this issue is so simple but its not clicking.

Thanks
Paolo




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Highlight Seltext And Get The Seltext To Form1.text1.text
Hello guys,

how can i get seltext copied from another textbox or webpage text (like this text) when u double click this text it will highlight right? then how to copy the highlighted seltext to form1.text1.text? can u guys provide me some source code example..i took a long days to search this code using mr. google..

Seltext And Get Focus Textbox -- See Seltext When Not Focused :S
I really have no clue if that is possible in vb since im a total newb,
I also have no clue if it has already been awnsered but I can't find it on the forum so I guess not.

I have 2 form, a form with a text editor similar to notepad
 and another one obtained by clicking the search button
-- frmediteur(text form) and frmremplacer (find form) here is the code of the button.

Code:
Private Sub cmdsuivant_Click()

Dim intposition As Integer
Static intdebut As Integer


'If Not trouver Then frmediteur.txtediteur.SetFocus
MsgBox trouver
strrecherche = txtrecherche.Text
On Error GoTo erreur

    If Not trouver Then
        intposition = InStr(1, frmediteur.txtediteur.Text, strrecherche, 1)
        If intposition = 0 Then
           MsgBox strrecherche + " est introuvable", vbExclamation, "Recherche terminé"
        Else
           frmediteur.txtediteur.SelStart = intposition - 1
           frmediteur.txtediteur.SelLength = Len(strrecherche)
           'MsgBox "J'ai trouvé le mot " + strrecherche + " a la position " + Str(intposition)
           cmdsuivant.Caption = "Suivant"
           trouver = True
           intdebut = frmediteur.txtediteur.SelStart + 2
        End If 'TEST
     Else
        intposition = InStr(intdebut, frmediteur.txtediteur.Text, strrecherche, 1)
        If intposition = 0 Then
           MsgBox "Recherche Terminé", vbInformation, "Fin"
           trouver = False
           cmdsuivant.Caption = "Chercher"
        Else
           frmediteur.txtediteur.SelStart = intposition - 1
           frmediteur.txtediteur.SelLength = Len(strrecherche)
           intdebut = frmediteur.txtediteur.SelStart + 2
        End If
     End If

Exit Sub
erreur: Exit Sub
'MsgBox Err.Description

End Sub


everything works fine and im happy I pass alot of time on this rofl
but! the selected text doesn't appear unless I click on frmediteur - form - if I stay on frmremplacer - form - I can't see what is selected...
I can include screenshot, but im sure someone see what I mean.

I was wondering what is the solution for that kind of problem,
I heard about activex but I don't find anything related to my topic anywhere (maybe I don't know how to search :P)

thanks in advance.

- Teezee

ps: Just to specify, that button do a find on the first click and a find next on the second and other click until the end is reached.



Edited by - teezee on 2/9/2005 12:37:51 PM

SaveFile()
Okay, here's the code:

Code:
Call SavePicture(Picture1.Picture, "C:windowsdesktopIcon.ico)


Picture1.picture does contain a picture, and i don't know what is wrong with it? Please help.

SaveFile As PDF
Hello,

I recently found coding on your site that saves a MS Access file to .pdf and then emails it using MS Outlook (see FAQ703-2533).  I have attempted to run my code and keep receiving this MsgBox error "User-defined type not defined" at line:
Dim appOutLook As Outlook.Application
   
See my coding below for the CLICK event.  I'm just learning vb 6.0 and am unsure how to fix this problem.  I may have other coding problems with this CLICK event....haven't gotten that far yet.  Any help is greatly appreciated.  I'm running Office XP with Windows 2000/NT 5.0 environment.  Thanks!

Private Sub cmdPreviewRpt_Click()
On Error GoTo Err_cmdPreviewRpt_Click

    Dim stDocName As String
    Dim Name As String
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    
    Name = InputBox("Enter the name for the PDF file:", "PDF")
      
    Call SaveReportAsPDF("rpt_ExpenseRpt", "C:work" & Name & ".pdf")

    With MailOutLook
        .To = "Forms!frmOrder!PEmail"
        .Subject = "mail subject"
        .HTMLBody = "a HTML Body if needed"
        .Attachments.Add "C:Work" & Name & ".pdf", olByValue, 1, "" & Name & ".pdf"
        .Display
    End With
        stDocName = "rpt_ExpenseRpt"
        DoCmd.OpenReport stDocName, acPreview

Exit_cmdPreviewRpt_Click:
        Exit Sub

Err_cmdPreviewRpt_Click:
    MsgBox Err.Description
    Resume Exit_cmdPreviewRpt_Click
    
End Sub



RTB SaveFile Function
Um, i tried using the SaveFile function to save my txtMain.Text, the save was succesfully without errors, the only problem was the contents of the textfile contained information for font color, background color etc. Is this because i used the SaveFile for saving a standard text file, does it have to be a RTF file in order to use the SaveFile function?

Thanks

Richtextbox + Savefile ****
Hello all,

I have a small program that takes information from a database and compiles it to html. I am using a RichTextBox. Now my problem is, after i turned the present text into html, i got good html-text in the rtfbox. But if I know try to save it or anything it takes the makeup commandos from the RTB with it. So i got a lot of code in front and after the htmlpage

ANy idea how to solve this?

Greetz,

danielsan

OpenFile And SaveFile
Hi. I'm doing a questionnaire in VB and need the user to be able to save the questions (and the answers they have given) in a file and re-open it later to answer any questions which haven't been answered. i haven't a clue of the code so somebody help me, please!!!!!
Cheers

Richtextbox1.saveFile
richtextbox1.saveFile("FilePath",flags)

What is this flags used for?
What are the different values that can be passed to it(flags).?
When I save it to a txt file I could see additional text
like information of Font type,size etc.How do I save the
text in the RTF as a clear text file void of such info?

SaveFile Method
Hi,
I want to use SaveFile method in order to save the content of text Box into my local directory.
My code like this:
Text1.SaveFile("c:Tempforwei", 1)

The compiler keep giving me error. It can't save the content at all.

Any help will appreciated.


Allen

Help With RTB Savefile Text Formatting
The following codes works except that the text now has formatting info like {
tf1ansideff0{fonttbl{f0fnilfcharset0 MS Sans Serif;}}, /par and /tab all thru.

Is there a way to prevent this or a way to go about the replace function without using an RTB.


VB Code:
Private Sub Command1_Click()     RichTextBox1.LoadFile ("c:gpl_ai.txt")    a = "npt_override = 1.04"    b = Replace(RichTextBox1.Text, a, "npt_override = 1.08")    RichTextBox1.Text = b    RichTextBox1.SaveFile ("c:gpl_ai.txt") End Sub


Cheers, Jack

Savefile Or Text Parse
i wrote a code that communicates through a serial port and receives data as "lf99 9999" (without the quotes) and i do a text.seltext = text1.txt and a text.savefile rtftext .
now but when i open the file in notepad it doesnt look right it goes from left to right

ie.

lf99 99999    lf99 99999

how can i get it to save the file like so ..


lf99 99999
lf99 99999

i tried putting a vbcr after the text.seltext = text1.txt but it didnt work

thanks

Problem With RichTextBox1.SaveFile Method
The text I want to save is inside the textbox. This function is supposed to save the text in (rtf?) format to C:GitmailMessage Text.rtf. The file saves ok, however, when I open it, there's nothing inside. I also tried saving to a text file in plain text format, but that gives me a bunch of garbage.


Code:
rtbMessageText.SaveFile App.Path & "Message Text.rtf", rtfText

I also tried their numerical equivalents (0 for rtfText and 1 for rtfRTF, if I remember correctly) and got the same results.

Why Does It Save This Junk When I Use RTB1.SaveFile
Hi, I was experimenting with the common dialog 6.0 tutorial posted by Mike ( i think) and I kept getting this in my text file:

{
tf1ansiansicpg1252deff0{fonttbl{f0fnilfcharset0 MS Sans Serif;}}
viewkind4uc1pardlang1033f0fs17 Why is it adding this junk?
par }


As you can see: "Why is it adding this junk" was the original text. Is there a way to avoid this? Thx!

This is my code:

Private Sub Test_Click()

On Error GoTo ErrorTracker
With CommonDialog1
.DialogTitle = "Save"
.InitDir = "C:"
.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
.ShowSave
End With
RTB1.SaveFile CommonDialog1.FileName
Exit Sub
ErrorTracker:
MsgBox "Error: " & Error
End Sub

P.S. I hope this wasnt the wrong forum to post under..If so please point me to the right forum.

Rich Textbox Savefile Question
i'm making a simple html editor that allows you to insert tags instead of typing them ... i'm using a rich textbox for this so the tags can be a different color ... now when i save the code that i have is this:

dlgsave.showsave
txthtm.savefile dlgsave.filename

the dialog box comes up asking for a directory to save and saves it as a "htm" file ... however when i open up the file to view it in IE what i get is the following on the page:

{
tf1ansiansicpg1252deff0deftab720{fonttbl{f0fswiss MS Sans Serif;}{f1fromanfcharset2 Symbol;}{f2froman Times New Roman;}} {colortbl
ed0green0lue0;
ed0green0lue255;} deflang1033pardplainf2fs24cf1 par plainf2fs24cf0 testplainf2fs24cf1 plainf2fs24cf0 par plainf2fs24cf1 plainf2fs24 par }

why does this happen? - can't the file be saved into a proper htm file with the rich textbox ... i know there is some syntax to save as rtfRTF or rtfTEXT but can't it save as HTM ... how does MS WORD give you options to save as a HTM page

SelText
OK I think this is right but I'll check, does the SelText function just change a selected part in a string for example, if you had
"Hello welcome to the vb forum" and set SelText has
text1.selText = "vb"
vb would be the only part of the text (string) changed?

Seltext
'text1.setfocus'

When textbox is focused i want to select all text .

SelText
The combo boxes are filled. with the months---Jan,Feb,so on But, How do I select and save one of the Months in a cboBox to display in the datagrid and MSAsscess

SelText I Think?
In my current project I have a need to pass items into a text box and then to have those items change their format from normal to bold and the colour red. So if you can imagine, you click on an item in a list box and it then appears in the text box at the insertion point. I have the items appearing in the text box without any problem but the formatting is proving more tricky although I am sure the answer is simple.

I attempted to tackle the problem by taking the length of the text box len(textbox.text) and then subtracting the the length of the item inserted to use as a start point, then using seltext I attempt to select the item and then format it but it doesnt seem to be working, I suspect my syntax is incorrect? Can anybody help?

SelText?
If I have a string, for example, "UserName: How are you today?". How do I extract everything before the ":" in "UserName:" to get the result string "UserName"?

Thankz, Drew
Moses420ca@yahoo.ca?SUBJECT=I Love Your Stuff

SelText
i want the text in a textbox to be selected once the lostfocuss()
event is fired.

the foll code doent seem to work.

Private Sub Text1_LostFocus()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SelText = Text1.Text
End Sub

any tips?
also i dont understand the difference between SelText & SelLen?
someone explain

cheers
vijay

Seltext With Right Button
Is it Possible to highlight text (seltext) using the right button??

I'm trying to use

private sub rtfRX_mousedown (Button As Integer, Shift As Integer, x As Single, Y As Single)

if button = 2 then
aMsg = rtfRX.seltext
shiftchar aMsg
end if

the problem is aMsg is coming up empty..

thanks

Seltext Not Working
Can somone tell my why this is not working. I'm using a text box as an input for something else on the form. All I want is the text that is inthe text box already to be highlighted when a button on the form is pushed...

Text22.SetFocus
aStr = Text22.Text
Text22.SelStart = 1
Text22.SelLength = Len(Text22.Text)
Text22.Text = ""
Text22.SelText = aStr

I have even tried this with a RTB but can't get it to work...

Thanks

TxtMain.SelText?
Basically, i have a combobox which changes my textbox forecolor to the selected item. As shown:


VB Code:
Private Sub cboFontColor_Click()On Error Resume NextSelect Case cboFontColor.Text    Case "Black"    txtMain.ForeColor = vbBlack    txtMain.SetFocus    Case "Blue"    txtMain.ForeColor = vbBlue    txtMain.SetFocus    Case "Green"    txtMain.ForeColor = vbGreen    txtMain.SetFocus    Case "Red"    txtMain.ForeColor = vbRed    txtMain.SetFocus    Case "White"    txtMain.ForeColor = vbWhite    txtMain.SetFocus    Case "Yellow"    txtMain.ForeColor = vbYellow    txtMain.SetFocusEnd SelectEnd Sub


Only problem is, is that changes the WHOLE text to the specified color. I only need the selected text changing. I tried something like:


VB Code:
txtMain.SelText txtMain.ForeColor = vbYellow


But that errors(i took the On Error Resume Next handle out), Invalid Use of Property. What is wrong,

Thanks for any help

Selstart, Seltext?
how do you make it so when you click a botton it move to a box you want to type in?, ive totally forgot

Question About Using SelText
How would I use the SelText (or SelStart?) property of a Rich Textbox control to display only text the user inputs in bold type?

Rtb Seltext Font
How can I change the Font of a selected text, I wanted to use the commondialog1.showfont but it do not work, any idea ?

Ole Container And Seltext
Is it possible to reference the text selected in an ole container?

(Ex. I have a form with OLE1. In the container is a word doc with the first sentence selected.)

How can I reference form1.ole1.seltext?

Stephen Robertson

Help! Seltext In A Textbox
could anyone help me with the following , its driving me crazy!!.....

i am reading lines of text from a saved file using the LINE INPUT# statement. i need to put each line in the same textbox. In order to do this i need to add chr$(13) + chr$(10) so each line is separate. The problem i have is when i want to know the selstart of the selected text it adds 2 characters (the return and linefeed) to my seltext.

Is there a way of using the selstart without including these?

any ideas?

thanks.

SelText Alternative
This may seen like an odd request but is there a longhand way of replacing
seltext in this piece of code?

For i = 1 To Len(Answer)
'Loop Through Each Letter In Answer
IsIn = False
For j = 0 To 25
'Loop Through Each Letter In Alphabet
If Not cmdLetters(j).Enabled Then
If Mid(Answer, i, 1) = Chr(j + 65) Then
IsIn = True
txtAnswer.SelText = Chr(j + 65)
End If
End If
Next
If IsIn Then
Else
If Mid(Answer, i, 1) = " " Then
txtAnswer.SelText = ""
Else
txtAnswer.SelText = " * "
End If
End If
Next i

The SelText Subroutine???
I am trying to check what option is checked in a combo box. I was reading some documentation on SelText. It says...

______________________________________________
Property SelText As String
Member of VB.ComboBox
Returns/sets the string containing the currently selected text.

______________________________________________

So from what I understand no arguments are passed in and a string is returned. Here is my code below...
_______________________________________________
Private Sub calculateButton_Click()
Dim side As Variant
If (squareOption.Value = True) Then
If (cmbChoice.SelText = "Perimiter") Then
side = lengthText.Text
side = side * side
resultLabel.Caption = side
End If
End If

End Sub
_________________________________________________
What I am trying to do is calculate the perimiter if the combo box has "perimiter" selected. But I get run time error 380, invalid property value. Am I reading the documentation on this subroutine incorrectly, or what???

Any help would be greatly appreciated....

Getting .Text And .selText From WebBrowser
Hi,
I'm using WebBrowser control, and need some properties it doesn't have.
- Get browser's text as string (like .Text in richtext box)
- Get selected text as string (like .selText in richtext box)

I guess i should use API, but don't know how...

SelText Position In A Web Control
how i can find the SelText Start Postion and End Position in a Microsoft Web Control.i.e when i am in desgin mode whatever text i selected i want to display its Start x,y position and End x.y position in a contol.

The Best String Alternative To .seltext ?
Hi,

Quite a basic question now.
Sure, with a textbox selecting text and then storing that in a variable is easy using the .seltext property but what is the best way to "select" text in a non-oject orientated string.
Would it be best to use Instr() to find the word position at which you want to start and end and then loop through every letter betwen these values adding it to a different string (the "selection" string) ??

Much appreciated,

Jord

SelStart = The Beggining Of SelText
I Have an RTB and i have selected text i.e.

Seltext="DFGHJKIHLKJLKJ"

I want the cursor to go back to the begging of the seltext and leave the text selected.

So in other words Select "DFGHJKIHLKJLKJ" and move the cursor back in front of the "D".

This seltext can be anywhere in the richtextbox so it is variable.

THanks for the HELP!

Seltext Cursor Position
Hi
I am using the following code, whenever a user presses the "#" key, it will turn "#" color to red. Is there a way to position the cursor at the end of textbox. ie. so once the "#" is pressed typing will continue normally?

Any help would be appreciated,

Thanks

Kelly


Private Sub RichTextBox1_Change()
Dim Search, Where
Dim Value

Search = "#"

Where = InStr(RichTextBox1.Text, Search)

If Where Then '

RichTextBox1.SelStart = Where - 1 ' set selection start and
RichTextBox1.SelLength = Len(Search) ' set selection length.
RichTextBox1.SelColor = vbRed
RichTextBox1.SelStart = Where + 1
RichTextBox1.SelColor = vbBlack



End If
End Sub

Tweaking Seltext In Richtextbox
Hi just a quick question which has been annoying me. I have a rich text box with groups of text in (3 lines per group)...

If i search a rich text box for a unique string, how can i also select the line above and below this found text? I can't just search for the whole chunk of three lines... i won't go into it all, but it's just not viable because information is duplicated in some areas... but one line of each group is unique (the text i am searching for) and i want to select the whole group relating to it.

I thought perhaps you can make the rich text box skip to the previous line, then select through another line and then the last line to select the whole group. Any way i can do this?

Thanks,
James.

Getting Color Of A Character In An Rtf Box Without Using Seltext?
Is there a way to determine the color of a certain character in a richtextbox without highlighting it and returning the .seltext? because i'm sure it would greatly speed up my program.

SelText Stay Selected After Command.
I have a textbox, and a menu command, which changes the textboxes SelText by adding a "• " to the beginning. The thing is, after the program performs this command, the SelText is now unselected, which is annoying, because there are other menu commands like that one, and I want it all to stay selected.

Newbie Question; Sellength, Seltext, Etc.
hey.

I have a filelistbox and a (multiline) textbox on a form.

I want the user to be able to do the following:

1. doublelick a file in the filelistbox and have the filename be populated to a new line in the textbox. (this I can do).

2. Select a filename that's been put into the textbox simply by clicking the filename in the textbox (i.e. similar to the way a filename is selected in a filelistbox).

3. Rearrange the order of the filenames in the textbox by either drag and drop or command buttons (or both).

4. prevent a filename from being added to the textbox more than once.

It seems that I would have to use sellength, seltext, etc to make this work, but I'm not sure. Can someone point me in the right direction?

Thanks.

joshkatan

Selected Text By SelText Property???
Hello!

I have a form with a text box. I'd like to get a string of words selected by user. I inserted a button into form, the button has a code:

Private Sub btTest_Click()
If Me.CommentText.SelLength > 0 Then
MsgBox "Text selected is: " & Me.CommentText.SelText
Else
MsgBox "No text selected"
End If
End Sub

When running this code an error appeares saying that the control have to be focused before. If I change the code (below) the message box shows all text:

Private Sub btTest_Click()
Me.CommentText.SetFocus
If Me.CommentText.SelLength > 0 Then
MsgBox "Text selected is: " & Me.CommentText.SelText
Else
MsgBox "No text selected"
End If
End Sub

So, please, help me to solve the problem!

A Very Easy Hard Question ! (seltext)
Code:
text1.fontbold
text1.fontitalic
text1.fontunderline


No problems, the above I can do to make all the text in a box bold, italic, underline etc.

If I wanted just the selected highlighted text to be bold if I click a commandbutton, I think I have to use the seltext option, so I have been trying :


Code:
text1.seltext.fontbold


which does not work, all I have left to put here then is HHHHEEEEELLLLPPPPPP!!!!!! (please, alright then, pretty please).

(SelText GURUS) Find A Word In A Text Box
Hello, does any one know how to find a word in a text box and record the location without the use of any input/dialog boxes? I want to perform all functions directly in the code. Thanks in advance.

FORM CODE BELOW:

Private Sub Command1_Click()
Dim szFindString As String ' initial string to find
Dim hCmdBtn As Long ' handle of 'Find Next' command button
Dim strArr() As Byte ' for API use
Dim i As Integer ' position indicator in the loop

gHTxtWnd = rtbDisplay.hwnd

' Fill in the structure.
szFindString = "Code (if applicable)"

ReDim strArr(0 To Len(szFindString) - 1)

For i = 1 To Len(szFindString)
strArr(i - 1) = Asc(Mid(szFindString, i, 1))
Next i

frText.flags = FR_MATCHCASE Or FR_NOUPDOWN Or FR_NOWHOLEWORD
frText.lpfnHook = 0&
frText.lpTemplateName = 0&
frText.lStructSize = Len(frText)
frText.hwndOwner = Me.hwnd
frText.hInstance = App.hInstance
frText.lpstrFindWhat = VarPtr(strArr(0))
frText.lpstrReplaceWith = 0&
frText.wFindWhatLen = Len(szFindString)
frText.wReplaceWithLen = 0
frText.lCustData = 0

' Show the dialog box.
gHDlg = FindText(frText)

' Get the handle of the dialog box
hCmdBtn = GetDlgItem(gHDlg, 1)

' Get necessary value for calling default window procedure.
gOldDlgWndHandle = GetWindowLong(hCmdBtn, GWL_WNDPROC)

If SetWindowLong(hCmdBtn, GWL_WNDPROC, AddressOf FindTextHookProc) = 0 Then
gOldDlgWndHandle = 0
End If

End Sub

MODULE CODE BELOW:
Public Type FINDREPLACE
lStructSize As Long ' size of this struct 0x20
hwndOwner As Long ' handle to owner's window
hInstance As Long ' instance handle of.EXE that
' contains cust. dlg. template
flags As Long ' one or more of the FR_??
lpstrFindWhat As Long ' ptr. to search string
lpstrReplaceWith As Long ' ptr. to replace string
wFindWhatLen As Integer ' size of find buffer
wReplaceWithLen As Integer ' size of replace buffer
lCustData As Long ' data passed to hook fn.
lpfnHook As Long ' ptr. to hook fn. or NULL
lpTemplateName As Long ' custom template name
End Type

Public Declare Function FindText Lib "comdlg32.dll" Alias "FindTextA" (pFindreplace As FINDREPLACE) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function GetDlgItem Lib "user32" (ByVal hDlg As Long, ByVal nIDDlgItem As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function IsDlgButtonChecked Lib "user32" (ByVal hDlg As Long, ByVal nIDButton As Long) As Long
Public Declare Function GetDlgItemText Lib "user32" Alias "GetDlgItemTextA" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long

Public Const GWL_WNDPROC = (-4)
Public Const WM_LBUTTONDOWN = &H201

Public Const FR_NOMATCHCASE = &H800
Public Const FR_MATCHCASE = &H4
Public Const FR_NOUPDOWN = &H400
Public Const FR_UPDOWN = &H1
Public Const FR_NOWHOLEWORD = &H1000
Public Const FR_WHOLEWORD = &H2
Public Const EM_SETSEL = &HB1

Public Const MaxPatternLen = 50 ' Maximum Pattern Length

Global gOldDlgWndHandle As Long
Global frText As FINDREPLACE
Global gTxtSrc As String
Global gHDlg As Long
Global gHTxtWnd As Long

Function FindTextHookProc(ByVal hDlg As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Dim strPtn As String ' pattern string
Dim hTxtBox As Long ' handle of the text box in dialog box
Dim ptnLen As Integer ' actual length read by GetWindowString
Dim sp As Integer ' start point of matching string
Dim ep As Integer ' end point of matchiing string
Dim ret As Long ' return value for SendMessage

strPtn = Space(MaxPatternLen)

Select Case uMsg
Case WM_LBUTTONDOWN
' Get the pattern string
ptnLen = GetDlgItemText(gHDlg, &H480, strPtn, MaxPatternLen)

' Call default window procedure
If gOldDlgWndHandle <> 0 Then
FindTextHookProc = CallWindowProc(gOldDlgWndHandle, _
hDlg, uMsg, wParam, lParam)
End If

' Customize the winodw procedure
If ptnLen <> 0 Then
strPtn = Left(strPtn, ptnLen)
SetFocus gHTxtWnd

' Get the MatchCase option
If IsDlgButtonChecked(gHDlg, &H411) = 0 Then
sp = InStr(LCase(gTxtSrc), LCase(strPtn))
Else
sp = InStr(gTxtSrc, strPtn)
End If

sp = IIf(sp = 0, -1, sp - 1)

If sp = -1 Then
Call MessageNoFound
Else
MsgBox "Begin Code Extraction?"
End If

ep = Len(strPtn)
ret = SendMessage(gHTxtWnd, EM_SETSEL, sp, sp + ep)
End If

Case Else
' Call the default window procedure
If gOldDlgWndHandle <> 0 Then
FindTextHookProc = CallWindowProc(gOldDlgWndHandle, _
hDlg, uMsg, wParam, lParam)
End If
End Select
End Function

Sub MessageNoFound()
MsgBox "No matches found"
End Sub

This Is A Tough Problem - Textbox (SelText) Related!!
Hi all,

This problem is driving me crazy and is becoming a waste of time.

Here it is:

I have created an app. that allows the user to cut-and-paste text into a text box and then "mark-up" the text with a pseudo-mark-up language (Italics, Bold, Underline, Email etc.) This is very similiar to the form that is used here to post a message, but it is a VBA program.

It allows the user to highlight the desired text, click the desired button and then the text is surronded by the "mark-up" tags like so:
{B}This is the highlighted text{/B}

Everything works fine, except for one little glitch:

The problem is that as soon as they alter the text in the text box and then highlight something the SelText property doesn't "grab" the desired text and ends up inserting the "tags" at the beginning. If the user then re-highlights the text, it works properly

If they don't alter the text and just cut-and-paste and then mark-up, it works nicely.

If anyone has any suggestions as to why this is happening or how to fix the glitch, it would be much appreciated. This problem is driving me bananas!!!!

As an aside, I capture the selected text on the Lost_Focus of the text box and store the values and data globally so when the BOLD (as an example) is clicked it has the data already captured.

Thank you in advance

RichTextBox1.SaveFile App.Path && "SSnp.rtf", RtfRTF
RichTextBox1.SaveFile App.Path & "SSnp.rtf", rtfRTF Saves as rtf vbut i wana save ti as .conf file hwo woudl i do

&lt;input Type="submit" Name="op-savefile" Value="Save"&gt; - How To S
<input type="submit" name="op-savefile" value="Save"> - How can you submit this button through visual basic in a webbrowser?

Copyright © 2005-08 www.BigResource.com, All rights reserved