Link to home
Start Free TrialLog in
Avatar of mcanepa
mcanepa

asked on

Extracting data from a string...HELP!

I need to select data from a sting (in a listbox).

The string in the list box is this:
(txtEmployeeName.Text & ":" & vbTab & txtSsn.Text & ":" & vbTab & txtPieceWork.Text)

I need to extract the piecework integer (txtPieceWrk.Text)from the string in order to calculate it with the price.
 
So far I have this, but I keep getting error messages:
NOTE: PieceWorkPay is a private function.

  strEmplySel = lstEmployee.List(lstEmployee.ListIndex)
    intPieWrk = InStr(1, strEmplySel, ":")

    If intPieWrk > 0 Then
       
        sngTotal = PieceWorkPay(Mid$(strEmplySel, intPieWrk + 1))
   
    End If

Please Help!
Thanks,
Maryann
Avatar of TigerZhao
TigerZhao

  intPieWrk = InStrRev(strEmplySel, vbTab)
ASKER CERTIFIED SOLUTION
Avatar of dipeshnepal
dipeshnepal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

dim arFields() as string
arfields=split(txtEmployeeName.Text & ":" & vbTab & txtSsn.Text & ":" & vbTab & txtPieceWork.Text, vbtab)

this will give you this array:
arFields(0)=txtEmployeeName.Text
arFields(1)=txtSsn.Text
arFields(1)=txtPieceWork.text


Hope this helps
the most simple way would be to try this :

*smiles*

msgbox txtPieceWork.Text
Dim l() as string
Dim str as string
Dim strPieceWork as string
str=txtEmployeeName.Text & ":" & vbTab & txtSsn.Text & ":" & vbTab & txtPieceWork.Text

l=Split(str, vbTab, vbTextCompare)
strPieceWork = l(2)