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




Multiple Replacement Functions But Can't Make It Swap!


Hello,
Thanks a lot for replying so fast. I tried running the code you sent and it was fine: It changed the words round and replaced just like I wanted. I added wildcards and that worked too.
However, when I tried to add entries to the array, it refused to swap the words round.
In these following two examples, I want to replace
a) any word beginning with “L” by “SING” and place it in front of the word that comes before it:
AND,
b) any word beginning with “C” by “COMPLAIN” and place it in front of the word that comes before it:

So if I take the following:
“She said she’d SOMETIMES LIE but then again, her brother said she’d OFTEN COUGH – I would STILL COMPETE but I NOW LIE

The result I WANT is:
“She said she’d SING SOMETIMES but then again, her brother said she’d COMPLAIN OFTEN– I would COMPLAIN STILL but I SING NOW

Help! The result I GET is:
“She said she’d SOMETIMES SING but then again, her brother said she’d OFTEN COMPLAIN – I would STILL COMPLAIN but I NOW SING
(i.e., the words are replaced but not swapped)

What am I doing wrong now?
I had to add some bits of code, so I wonder if I’ve put my Do While/loop in the correct place?
Thanks for your help so far.. I’m pleased . But if you can help me really fix this I’ll be an even happier man!

Here’s my code then:
Option Base 1
Sub Swop_and_Replace()
Dim tableau
Dim i As Integer

tableau = Array("<(l*)>", "SING", "<(c*)>", "COMPLAIN")

Set myRange = Selection

For i = 1 To UBound(tableau) Step 2
Do While Selection.Find.Found
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.TypeText Text:=tableau(2) & " "
Selection.Find.Execute
Loop

With Selection.Find
.Text = tableau(1)
.Forward = True
.Wrap = wdFindStop 'instead of wdFindAsk that prompts you to check each time
.MatchWildcards = True 'because I'm using wildcards to capture similar words
End With

myRange.Find.Execute FindText:=tableau(i), ReplaceWith:=tableau(i + 1), Replace:=wdReplaceAll


Next i

End Sub




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Swap Chains And Multiple Targets
I am working on a dx application that uses multiple render targets. I have written the whole primitive engine into a vb class module. I have limited success with rendering to multiple windows, sometimes when I attempt to create a new swap chain with the createadditionalswapchain function, it gets an automation error, and posts a negative number. It appears to be rather consistent that the 4th additional window I add will get the automation error. I have the windows setup in the following manner.

(Main window)
d3dpp(0).Windowed = 1
d3dpp(0).SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
d3dpp(0).BackBufferCount = 1
d3dpp(0).BackBufferFormat = mode.Format
d3dpp(0).hDeviceWindow = Form.hwnd

(child windows)
d3dpp(UBound(d3dpp())).Windowed = 1 'True
d3dpp(UBound(d3dpp())).SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
d3dpp(UBound(d3dpp())).BackBufferFormat = mode.Format
d3dpp(UBound(d3dpp())).hDeviceWindow = Form.hwnd
Set swap(UBound(swap())) = D3DDevice.CreateAdditionalSwapChain(d3dpp(UBound(d3dpp())))

where I am settting the swap device is where I will *somtimes* get an error, but the data is always the same... except for the hwnd of the form. Any help would really be appreciated.

EDIT: I should also note that I am using dx 8.1
EDIT2: Problem solved, I did an error lookup on the error and it is an out of video memory :/

Multiple Replacement In String
Hi,
I have three different values in a variable strVar, %a, %b, %c sorted random (ex. %a-%b(%c) or %b//%c__|,%a). Anyhow, I would like to replace these strings at the same time with three variables - strA, strB, strC.
But I have a problem when I try to replace the strVar with my three variables - I don't know how to do at the same time, because if I try to solve the problem by replace one by one I don't manage to do it. Is there a commando for me to use or do you want to create an function to me? That would be awesome!

Make Replacement In Many Html Pages In Frontpage
I'm looking for a solution to:
make some automatics find and replace in many pages.
many thanks

How To Swap Image When Mouse Over In VB (Like Swap Image In Html)?
Did you ever seen website ,when mouse over picture image will change.How To?
Thank you

How Do I Make And Use Functions?
can someone give me an example of making a function

How Do You Make Your Own Functions?
I have missed how to do this somewhere along my path of learning.

How do you send and get information from a function.

How do you send the information to the function? Like this?

Code:

private sub

findtime("3:30 am", "4:30 am")
label2.caption = totaltime

end sub



Is this how you send it back?

Code:

Public Function Findtime(startime, endtime)
Dim totaltime as date

totaltime = datediff(n,starttime,endtime)
return totaltime
end function



Up to this point I haven't used any functions other than internal ones. If I knew how I could get rid of alot of code.
Thanks for any info

Multiple Functions Or Subs
I have a sub routine (drawtree) that recursively draws items on a treeview. This subroutine also needs to check for continuous loops and uses the (checkloop) sub routine that I created. As the program stands at the moment if a loop is found the checkloop sub is exited and control is then returned to the drawtree sub. I want control to then be passed back to the initial calling sub which is a drag-drop onto the treeview.

My question is how should I acheive this, I am thinking that maybe the best way would be to change these sub's into functions and return a boolean value, and act upon that. Is my assumption correct or is their a better way.

Arrays Vs. Multiple Functions
If you have a string that will be split into three specific pieces of information, what is the best way to partition this string? As individual functions, pass the string to one function and return and array with the three sub-strings, or is there another method?

Thanks

How To Make Functions Public In A DLL
I was wondering how I would make a function public in a DLL and access it from a form in another project just like I would access a public function in a module from the same project. I want it to act just like any function in VB except it has to be part of the DLL.

I tried putting public functions in a class in the DLL project, I tried putting the functions in a module in the DLL and I couldn't access any of them from the form in the other project without putting the name of the DLL infront of the function I was trying to reach.

I thought that putting it in a class module and chosing "GlobalMultiuse" for its instancing would make it available like any other public function in a module. I guess that just makes it so you don't have to use Set = , but you still have to reference it using MyDLL.MyFunction.

(VB6)how To Make Functions In The Module?
Hon'ble gurus,
I use VB6. I want to know how to make a function for the following. I have a for loop to get the years(from 2006-2010) in a comobbox in its GotFocus event in many forms. In different forms in the respective combobox's GotFocus event I write like this: e.g.

Private Sub Combo1_GotFocus()
dim i as integer
for i=2006 to 2010
combo1.additem i
next i
End Sub

Can a Function for this be made(and be written in a Module) so that in the respective comboBox's GotFocus event I can call the function? The Years mentioned will be seen in the comboboxes. Please help me.

pkb_pkb

[Newbie] Multiple Functions From One Function?
You've been warned!

I haven’t done any programming since the early 1990's, mainly Pascal and Qbasic (I think), well, I've decided to spend some time with VB, Mainly to get some insight and refresh some calculus.

Here is the deal; I've set out to make a complete financial derivatives "calculator", nothing breathtaking, but a good opportunity for me to refresh some calculus while i learn some VB. The whole section dealing with options is just about done, except for some minor errors in the approximation of American options, one more evening and I'm there (hopefully). My first app consists of >1300 lines (not counting comments), this is mainly due to the fact that a lot of the functions could be merged into one, if only I knew how:

To illustrate the current situation :

Function func1(a, b, c, d)
Dim g1, g2 As Double
g1 = a + b + c + d
g2= -a - b - c - d
func1 = g1 + g2
End Function

Function func2(a, b, c, d)
Dim g1, g2 As Double
g1 = a + b + c + d
g2= -a - b - c - d
func2 = g1 / g2
End Function

Private Sub cmdCalculate_Click()
Text1 = func1(Label1, Label2, Label3, Label4)
Text2 = func2(Label, Label2, Label3, Label4)
End Sub

There must be a way to do something similar to the illustration below I've googled the internet but to no avail (I might be looking in the wrong direction though):

Function func(a, b, c, d)
Dim g1, g2 As Double
g1 = a + b + c + d
g2= -a - b - c - d
func1 = g1 + g2
func2 = g1 / g2
End Function

Private Sub cmdCalculate_Click()
Exec func(Label1, Label2, Label3, Label4)
Text1 = func1
Text2 = func2
End Sub

What do experienced VB programmers do in this scenario?

Ygg

Call Multiple Functions At One Time
hey, I need to call more than one function at a time, not necessarily similtaneously, but perhaps a few milli-seconds apart. I tried stacking call commands on top of each other in code like:

Code:
call function1()
call function2()


..and of course i was disappointed to see each wait till the first to be called has finsihed then the next call would run.. so how can I run more than one function at one time?? If even possible.. I think maybe an api timer?? Any help? thanks



Edited by - 3mu180r on 5/29/2005 12:01:18 AM

How To Make VB ActiveX Dll Functions Visible To VC++
Hello,
I am facing a problem. I am trying to call a dll file which is made in
VB in VC++ but VC does not access the fuctions that are in VB dll. What is the
problem. The DLL is a VB ActiveX DLL and when I view the dll through a DLL Viewer
it only shows the functions

1 0 DllCanUnloadNow (00002756)
2 1 DllGetClassObject (0000272A)
3 2 DllRegisterServer (00002740)
4 3 DllUnregisterServer (00002714)

which I think are added by VB wizard. and I can access these functions in VC.
How can I make it possible that VC can also access my methods or functions which
are defined in VB Dll.
Waiting for your kind reply,
Farhan Zia.

String Arrays.. Anyone Have Some Functions To Make Their Use Easier?
Working with string arrays is ridiculously frustrating in VB
The whole Redim Preserve bothers me to no end..

Anyone have any funcitons to make their use easier?
For example, if you have an array of 5 strings, how could you delete the 3rd string, leaving you with an array of 4 strings? The sizes of string arrays I will be using are pretty large, so moving the values of 'higher' array numbers 'down' to fill the gap will be too slow. And collections/dictionaries are also too slow

Str(0) = "a"
Str(1) = "b"
Str(2) = "c"
Str(3) = "d"
Str(4) = "e"

leaving you with
Str(0) = "a"
Str(1) = "b"
Str(2) = "d"
Str(3) = "e"

How To Make Functions With Arguments In Crystal Report
can anybody tellme how to write user-defined functions or formulas that take arguments in crystal reports?

for examples : i want to make one functions like converttens(stringvar x)

pari_java
"Tough days never last, Tough people do"

Simple Question: How Do You Set Multiple Functions To A Command Button?
I'm making my first game with VB. I taught myself out of one of those "Learn VB in 21 days" books. My game is going to be a simple text adventure and I just need to know how to set multiple functions to a command button.

I mean like, when you click on the button it displays text. When you click it again it clears that and displays more text.

Any help in this feild would be much abliged. Thanx in advance.

Creat View For 2 Tables With Multiple Aggregate Functions
Ok..Ill try and explain this as best I can I have two tables related by the field(memno)

From TBlProspect member I need to get (principal,state,coc,phone)
From Tblcontributions I need (memno,contribututionDate,contributionAmt)

Now.in tblcontribution the member number may be repeated as they may have contributed on a past date.

my goal...creat a view that will show all distinct memno's from both tables..along witht he fields I listed above



thanks in advance!

Passing A HDC To A Linked DLL File And How To Make VB Compatable C++ Functions
Can a Linked DLL use a passed hDC to modify an image?

What is the special way to declaring C++ function so that they can be used within VB?

How Do You Make Multiple Tables
I used the below code to make a database with one table. Tried with no success to make an additional table by duplicating the table creation code. Question: How do I create a second table. Also, how do I index it? - Steve

Private Sub builddb()
'
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
CurDir & "airmen_test.mdb"
Dim objcat As ADOX.Catalog
Dim objMyTable As New ADOX.Table

Set objcat = New ADOX.Catalog

objcat.Create strConnection
objcat.ActiveConnection = strConnection

With objMyTable
.Name = "tbl_dom_info"
.Columns.Append "first", adVarWChar, 20
.Columns.Append "middle", adVarWChar, 20
.Columns.Append "last", adVarWChar, 20
End With
objcat.Tables.Append objMyTable

Set objMyTable = Nothing
Set objcat = Nothing

End Sub

Make A Number A Multiple Of 24...
Whats the best way to make a numbmer a multiple of 24...
EX:

12 = 24
72 = 72
97 = 120
46 = 48
etc... it must round up...

Thanks!

Is The Only Way To Make Multiple Instructions...
What is the way to make multiple instructions happen in order, from a Command1_Click()?

I was earlier suggested that I use a timer, yet Im not so sure that, that is proper. What would YOU do to have three instructions take place in ORDER, after a command1_click()?
(It's got to be in order not all at once.)

Many thank you's to ya,
Daniel Christie

How Do I Make It So I Can Go Through Multiple Forms In My Program?
Ive finished my program, but i have one problem. I cant just be able to go through the forms. Can someone help me?

Make Recordset Available To Multiple Forms
Guys

How can I create a recordset in one form and still have it available in another?

I need to be able to select a record then, depending on a few things, update it in a later form.

Cheers

How Do You Make Multiple Line In A MsgBox Window
Hi Everyone,

I am trying to figure out how to make multiple lines to be displayed in a MsgBox window. The information to be displayed makes for a long window and I would like to shorten it. Kind of like what wordwrap does.

thx,

IF

Make Sure Txtbox Is Not Empty...for Multiple Txtboxes
Can someone tell me a neat way to check many text boxes to make sure there is some value in it?

I have a form that the user enters information into and I don't want them to be able to print a report with any of the text boxes empty....

How To Make MDI Form To Support Multiple Set Of Menus?
How to make MDI form to support multiple set of menus?

I am designing a MIS application where multiple users will log-in to the MIS application.

It requires different combination of menus in MDI form depends upon the user requirements. The problem is that MDI parent form supports only one set of Menu and making use of 'hide menu' option is of no much use.

What I need is that:

1. Is there any way to show different set of menus in MDI parent form depends of user who logged-in?

2. Adding a different menu in MDI child form doesnt solve my problem, as I expect parent MDI form must have required menu during user session irrespective of which form he is using.

How To Make Multiple Queries On One Data Report
Hi there, I Want To Design A Data report, So I Added A data environment & Data report , Created A Connection & Command1, in Command1 I Use SQL Query, So I need To Get Multiple Values From Different Tables,So:
i write An SQL Query:
SELECT * FROM students WHERE (SName = ?)
So I Can bound the result to textboxes on the report, but i need also to bound other results from different queries,
i tried to make another command, but the problem is that the data report is taking on command a once ,
wish to find an answer,

How To Make A Multiple Connection Chat Room?
I'm designing a chat room with visual basic 6 enterprise.. and i'm usin da winsock control.. but how can i let more than 2 people talk.. kinda like an aim/icq chatroom.

any help is welcome
-da404LewZer

Quick Q- How Do You Make A Program With Multiple Forms End When The X Is Clicked?
My program has multiple forms and I want to make it actually end when I click the X button to close it. Right now it disappears but is still visible in ctrl-alt-delete. Yes, I know this has been answered a thousand times before. Just make it a thousand and one please...

Swap Red And Blue
This is what I'm using to swap the red and blue channels from a RGB colour value:

Code:
LeftByte = Col And &HFF0000
MiddleByte = Col And &HFF00
RightByte = Col And &HFF
Col = ((RightByte * 256) Or MiddleByte) * 256 Or LeftByte

and I'd like to know if someone can make this more simplified and, specially, faster for when you have to do this for all the pixels in an image.

How Do I Swap For Sorting
Hello Can Anyone Help


Code:
Private Sub Swap(ByRef A As String, ByRef B As String)
Dim T As String

T = A
A = B
B = T
End Sub



Private Sub cmdSort_Click()

Open "swapsort.Dat" for Input as #1
While Not EOF(1)
c% = c% + 1
ReDim a$(1 To c%)
ReDim b$(1 To c%)

Input #1, a$(c%), b$(c%)
Wend
Close #1

Open "swapsort.Dat" for Output as #1
For i% = 1 To c%
For j% = i% + 1 To c%
If a$(i%) > a$(j%) Then
What to write here For SWAP .............
Swap a$(WHAT......%)
End If
Next j%
print #1, A$(i%), b$(i%)
next i%
Close #1
End Sub


Thanks

Sam F

Control Swap
I have a large VB project that uses a 3rd party control that I need to replace with another 3rd party control. For example, I have to replace all my current command buttons with a new set of buttons. Is there any automated or speddier way to do this rather than replacing each instance by hand?

Thanks!

Swap Procedure?
Hi,

I pretty new to VB and am getting really stuck on the Swap subroutine. For example if i wanted to take two integer parameters and swap their contents how would i write the code?

eg. IntA = 10
IntB = 15 Swap (intA, intB)
intA will hod 15 and intB will hold 10

Thanks.

Shell Swap...little Help
I'm writing a very liteweight shell swapping utility for windows. I've run into a problem with loading explorer.exe as the shell. I'm not sure how to execute explorer.exe in a way to load the entire desktop(systray and all) with it. If you know of a method of doing so, please respond.


-note
currently using shell() to run explorer.exe on startup. This is obviously note correct so don't suggest this method.

Swap Out Graphics
I have a Help/About form that has a graphic in the background.

I would like to have that graphic change every once in a while, so each time you Help/About, you see a different graphic.

Problem is, I have NO CLUE how to address this.

Any pointers would be greatly appreciated!

Thanks,

Swap The Buttons !
How can "delete" act like "backspace" and "backspace" like "delete" in a RichTextBox..

Image Swap
Say I have "picture1.gif" "picture2.gif" and "picture3.gif"

Ok. I need code to say that if commandButton1 is enabled, "picture1.gif" will show. if commandButton2 enabled, picture2.gif will show, and so on for the last button.

Ok, thanx.

Image Swap
if my label is "I am Happy!!" how can I get an image to show a happyface "happy.gif" in Picture1,
and if label is "I am Sad.." to put sad face "sad.gif" in picture1?????????????

( I'm only a beginner!! )

Bit Swap Within A Byte
I need to take an 8 bit word and switch the order of the bits, this isn't an endian change. More like a mirror image of the byte.

It is only 8 bits making b0 = b7, b1 = b6... etc

Is there an algorithm out there, I can think of some brute force methods. But I'm looking for something not as time consuming as these brute force possibilities because I have to do this alot, constantly.

Thanks

Ed

Form Swap
Can anyone advise on the cleanest way of selecting one form from within another and then hiding the previous form.
Ive got this working but very untidy.

How To Swap Records
hi,

    i'm using an ado control to access a access database and datagrid control to display the records. where i'm able to delete and update those records. but the real problem is, i want to swap those records i.e., interchanging / moving up or down.

    how to interchange the records in a datagrid or using some other grid control.

   can anyone help me to get rid of this problem as far as possible.

Thanks in advance,
Mukundhan. s

Swap Control
I want to swap two controls.
Here is the source that I made.
----------------------------------------------
Private Sub cmdSwap_Click()
Dim tmpLabel As Label
Dim tmpPic As PictureBox
Dim tmpLEAD As LEAD

Set tmpLabel = labelXray(0)
Set tmpLEAD = leadXray(0)
Set tmpPic = pictureBoxXRay(0)

labelXray(0) = labelXray(1)
labelXray(1) = tmpLabel
leadXray(0) = leadXray(1) &lt;===== error occurs when it runs
leadXray(1) = tmpLEAD
pictureBoxXRay(0) = pictureBoxXRay(1)
pictureBoxXRay(1) = tmpPic

End Sub
---------------------------------------------
But error occurs when it runs like following.

Run-time error '438':
Object doesn't support this property or method.

I think there are problem in my way to swap(or assign) control.
Could anyone who know it let me know?


DonYoung,Jeong

Info Swap
I need to use VBA in Word 2000 to access files in a directory, depending on date, and pull information from bookmarked fields and put them into an array. I am new at VB so if there is a reference book or some other information that could help me out, please let me know. Thanks

Swap Addresses Of Two Variables
I have a large bitmap array which I process in order to rotate it by say 30 degrees or whatever. In this process I have 4 lines of code which move Alpha and the three colours Red, Green and Blue as follows:


Code:
'Change the Alpha
bytDestImage(3, lngX, lngY) = bytSourceImage(3, lngXSource, lngYSource)
'Change the red
bytDestImage(2, lngX, lngY) = bytSourceImage(2, lngXSource, lngYSource)
'Change the green
bytDestImage(1, lngX, lngY) = bytSourceImage(1, lngXSource, lngYSource)
'Change the blue
bytDestImage(0, lngX, lngY) = bytSourceImage(0, lngXSource, lngYSource)
Now, you will notice this is identical in memory with a Long Array (ie 32 bit) and if I could fool VB6 into swapping the address of the Byte Array with a Long Array I would be able to achieve the above in one line rather than 4 thereby speeding it up a lot.

I had hoped that something like the following would work but it does nothing (I had hoped that since this call is ByRef it would fool VarPtr into revealing its own address but no such luck)

Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
Destination As Any, _
Source As Any, _
ByVal Length As Long)
......
......

CopyMemory VarPtr(variable1), VarPtr(variable2), length
I realise I could swap the contents (as opposed to the addresses) but that obviously takes time and I am looking for a clever (albeit dangerous) trick. Any ideas?

Swap Items In Listview
Hello I have a scenario here.
I have a Listview and two command butons (up and down)
Initial Listview Items

A text1 text1
B text2 text2
C text3 text3 - Selected

now when the Up button this is what will happen

A text1 text1
C text3 text3 - Selected
B text2 text2

Hope someone here help me.

Thanks

Swap Items In Listbox
hi everyone, i am having a little problem here with my program. here is the scnario.

I have a listbox and two command button labeled up and down
what i wanted to do is when i clicked on the up button the selected item on the listbox will go up one step like this

A
B
C - Selected Item

when I clicked on the up button here is what should happen

A
C - Selected Item
B

I know there is alitle swapping here but i don't know where to start.

Thanks and I apprecitae if anyone can help me

BTW im using VB6

How To Swap The 4 Digits In One Text Box?
can someone help me on how to select 4 digit in one textbox and then swap them because i want to display those swapped digits in another labelbox

Quick Image Swap
Hi guys i just ran into a little problem/issue.

I'm using imageBoxes as buttons and when I click an imageBox i use the mouseDown method to load a new image in the imageBox, and on the MouseUp event I reload the first image... This is all working fine.

However the problem i'm having is for each button/imageBox I also assign it a keyboard shortcut that fires the imageBox's Click event (the form's keyPress event handles this). Now what I want to do is quickly swap the imageBoxes mouseDown and MouseUp images so the user can see that infact pressing the key on the keyboard performed the operation. I tried using the KeyDown to raise the ImageBox_MouseDown and the KeyUp to raise the ImageBox_MouseUp events but i think it's just happening too fast...

any ideas???

It's just a cosmetic thing but somewhat important.

Thanks

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