1jaws
asked on
combine creditcard fields
I have a textbox textcreditcardnum dropdown expiration month, dropdown expiration year and textbox creditID
I want to combine those values in one label by showing last four digits of the txtcreditcardnum and the rest of them..how can I do that?
I want to combine those values in one label by showing last four digits of the txtcreditcardnum and the rest of them..how can I do that?
or...
mylabel.text = textcreditcardnum.text.Sub string(tex tcreditcar dnum.text. Length - 4) & expirationmonth.selectedit em.text & " " & expirationyear & " " & creditID.text
mylabel.text = textcreditcardnum.text.Sub
finally...
mylabel.text = textcreditcardnum.text.Sub string(tex tcreditcar dnum.text. Length - 4) & expirationmonth.selectedit em.text & " " & expirationyear.selectedite m.text & " " & creditID.text
mylabel.text = textcreditcardnum.text.Sub
ASKER
yes, I need this in C# and i need xxx fields untill last four in creditcard number
Try this....
You will have to adjust the control names...
You will have to adjust the control names...
mylabel.text == textcreditcardnum.text.Substring(textcreditcardnum.text.Length - 4) + expirationmonth.selecteditem.text + " " + expirationyear.selecteditem.text + " " + creditID.text
with a semicolon at the end :)
You may wish to use this which is in C#
string ccnum = textcreditcardnum.Text.Substring(textcreditcardnum.Text-4);
txtResult.Text = ccnum.PadLeft(textcreditcardnum.Length, 'X') + " " + ddExpirationMonth.SelectedItem.Text + " " + ddExpirationYear.SelectedItem.Year + " " txtCreditID.Text;
// where ddExpirationMonth is the control ID of the dropdown expiration month and ddExpirationYear is the control ID of the dropdown expiration year and txtCreditID is the ID of the Credit ID textbox
Oops correction please.
string ccnum = textcreditcardnum.Text.Substring(textcreditcardnum.Text.Length-4);
txtResult.Text = ccnum.PadLeft(textcreditcardnum.Text.Length, 'X') + " " + ddExpirationMonth.SelectedItem.Text + " " + ddExpirationYear.SelectedItem.Text + " " txtCreditID.Text;
// where ddExpirationMonth is the control ID of the dropdown expiration month and ddExpirationYear is the control ID of the dropdown expiration year and txtCreditID is the ID of the Credit ID textbox and you may assign this to a text box txtResult or to a variable.
ASKER
it is exaclty what I was looking for but giving me error on the highliging txtCardID as a expecting ; it says
=ccnum.PadLeft(txtCreditCa rd.Text.Le ngth, 'X') + " " + ddExpirationMonth.Selected Item.Text + " " + ddExpirationYear.SelectedI tem.Text + " " txtCardID.Text;
=ccnum.PadLeft(txtCreditCa
you missed a +. i have modified your code as below. Please note that, the control IDs that I have specified are sample and you need to replace them with the actual Control IDs.
ccnum.PadLeft(txtCreditCard.Text.Length, 'X') + " " + ddExpirationMonth.SelectedItem.Text + " " + ddExpirationYear.SelectedItem.Text + " " + txtCardID.Text;
ASKER
string ccnum = txtCreditCard.Text.Substri ng(txtCred itCard.Tex t-4); on there I get error operator - cannot apply string and int it says
ASKER
i added like this
txtCreditCard.Text.Trim(). Substring( txtCreditC ard.Text.L ength - 4);
is it correct?
txtCreditCard.Text.Trim().
is it correct?
yes. sorry for that as i have once again posted the correct code above, just next to the incorrect one. You can refer to that above.
ASKER
perfect it works, only thing there are so close to each other I need to something maybe "/" to seperate values from each other ?
Yes you may separate each value by replacing the below
" "
with
" / "
" "
with
" / "
ASKER
I put those didnt look good, can we put like this to the string. is this correct way?
ccnum.PadLeft(txtCreditCar d.Text.Len gth, 'X') + " Exp Date: " + ddExpirationMonth.Selected Item.Text + " " + ddExpirationYear.SelectedI tem.Text + " Card ID: " + txtCardID.Text;
ccnum.PadLeft(txtCreditCar
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you soo much!!!!
I want to combine those values in one label by showing last four digits of the txtcreditcardnum and the rest of them..how can I do that?
Something like this...
mylabel.text = Microsoft.VisualBasic.Righ