Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ampersand(&) Eqivalent in Visual Basic.

Status
Not open for further replies.

APS

Vendor
Sep 25, 2000
53
0
0
US
Hi

Simple Question.

Can anyone tell me what the eqivalent command would be to use in VB for the Ampersand in VFP.

Thanks
Anthony
 
Not what I am looking for. Let me explain better.

In VFP if I had the following

cCounter = 0
dCounter = 0
eCounter = 0
oCounter = 0
TheLetters = "ECCDEO"
For cntr = 1 To Len(TheLetters)
Test = substr(TheLetters, cntr, 1)
If Test = "C" Or Test = "D" Or Test = "E" Or Test= "O"
cField = Test+"Counter"
&cField = &cField + 1
EndIf
Next cntr

The new values would be
cCounter = 2
dCounter = 1
eCounter = 2
oCounter = 1

Visual Basic does not like the &. I need to treat the contents of the cField variable as a character string literal.
 
Robert,

At first glance, I too thought he was asking for the VFP equivalent of VB's string concatenation (&). LOL

But I think he is asking for the VB equivalent of VFP's macro substitution (&).

APS,

IIRC, there is no exact correlation in VB of VFP's & command. That said, there are still ways of achieving the same result in VB, but you will have to code it differently.

Post the VFP code you are attempting to convert to VB and maybe we can assist you.
If you havent already, you may want to post this in the VB forum as well. Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
That is correct I am looking for the equivalent of VFP's macro substitution (&). Sorry I did not explain it as such.

If you could tell me how to achieve the following in VB that would take care of the problem. Thanks for the HELP!

cCounter = 0
dCounter = 0
eCounter = 0
oCounter = 0
TheLetters = "ECCDEO"
For cntr = 1 To Len(TheLetters)
Test = substr(TheLetters, cntr, 1)
If Test = "C" Or Test = "D" Or Test = "E" Or Test= "O"
cField = Test+"Counter"
&cField = &cField + 1
EndIf
Next cntr



 
Use a Case statment:

Code:
For cntr = 1 To Len(TheLetters)
    Test = Mid(TheLetters, cntr, 1)
    Select Case Test
        Case "C"
            cCounter = cCounter + 1
        Case "D"
            dCounter = dCounter + 1
        Case "E"
            eCounter = eCounter + 1
        Case "O"
            oCounter = oCounter + 1
        Case Else
         'problem
    End Select
Next cntr

or use the IIF() function:

Code:
For cntr = 1 To Len(TheLetters)
    Test = Mid(TheLetters, cntr, 1)
    cCounter = IIf(Test = "C", cCounter + 1, cCounter)
    dCounter = IIf(Test = "D", dCounter + 1, dCounter)
    eCounter = IIf(Test = "E", eCounter + 1, eCounter)
    oCounter = IIf(Test = "O", oCounter + 1, oCounter)
Next cntr
Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Or you can use an Array
[tt]
TheLetters = "ECCDEO"
Test4Chr = "CDEO"
lnArrayLen = len(TheLetters)
dimension laArray(lnArrayLen)
store 0 to laArray
for lnX = 1 To anLen
if substr(TheLetters,lnX, 1) $ Test4Chr
laArray[lnX] = laArray[lnX] +1
endIf
endfor
*
David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
Dont take this the wrong way, Dave, but a few comments about your post:

1. He needs VB syntax, not VFP.

2. Where did this variable (anLen) come from? Should it be lnArrayLen?

3. Even executing this code in VFP doesnt yield the correct result. The correct result would be an array with 4 elements; 2 elements equal to the value of 1 and 2 elements equal to the value of 2.
Your algorithm incorrectly dimensions the array to 6 and simply adds 1 to each element of the array, resulting in an array with 6 elements, all equal to the value of 1.

No offense. Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Dave how have you been you bugger er booger? Haven't talked to you or seen you on the ActiveList in a while. Hope everything is going good since last we chatted.

Sorry if posting a non code post offends anyone. :eek: John Durbin
john@johndurbin.com
MCP Visual FoxPro
ICQ VFP ActiveList #73897253
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top