• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

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?
0
1jaws
Asked:
1jaws
  • 7
  • 6
  • 5
1 Solution
 
RobertNZanaCommented:
:      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?

Something like this...
mylabel.text = Microsoft.VisualBasic.Right(textcreditcardnum.text, 4) & expirationmonth.selecteditem.text & " " & expirationyear & " " & creditID.text
0
 
RobertNZanaCommented:
or...

mylabel.text = textcreditcardnum.text.Substring(textcreditcardnum.text.Length - 4) & expirationmonth.selecteditem.text & " " & expirationyear & " " & creditID.text
0
 
RobertNZanaCommented:
finally...

mylabel.text = textcreditcardnum.text.Substring(textcreditcardnum.text.Length - 4) & expirationmonth.selecteditem.text & " " & expirationyear.selecteditem.text & " " & creditID.text
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
1jawsAuthor Commented:
yes, I need this in C# and i need xxx fields untill last four in creditcard number
0
 
RobertNZanaCommented:
Try this....

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

Open in new window

0
 
RobertNZanaCommented:
with a semicolon at the end :)
0
 
CB_ThirumalaiCommented:
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

Open in new window

0
 
CB_ThirumalaiCommented:
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.

Open in new window

0
 
1jawsAuthor Commented:
it is exaclty what I was looking for but giving me error on the highliging txtCardID as a expecting ; it says
=ccnum.PadLeft(txtCreditCard.Text.Length, 'X') + " " + ddExpirationMonth.SelectedItem.Text + " " + ddExpirationYear.SelectedItem.Text + " " txtCardID.Text;
0
 
CB_ThirumalaiCommented:
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;

Open in new window

0
 
1jawsAuthor Commented:
string ccnum = txtCreditCard.Text.Substring(txtCreditCard.Text-4); on there I get error operator - cannot  apply string and int it says
0
 
1jawsAuthor Commented:
i added like this
txtCreditCard.Text.Trim().Substring(txtCreditCard.Text.Length - 4);
is it correct?
0
 
CB_ThirumalaiCommented:
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.
0
 
1jawsAuthor Commented:
perfect it works, only thing there are so close to each other  I need to something maybe "/" to seperate values from each other ?
0
 
CB_ThirumalaiCommented:
Yes you may separate each value by replacing the below
      " "
with
     " / "
0
 
1jawsAuthor Commented:
I put those didnt look good, can we put like this to the string. is this correct way?

 ccnum.PadLeft(txtCreditCard.Text.Length, 'X') + " Exp Date: " + ddExpirationMonth.SelectedItem.Text + " " + ddExpirationYear.SelectedItem.Text + " Card ID: " + txtCardID.Text;

 
0
 
CB_ThirumalaiCommented:
it is correct in syntax.  but i don't know the actual requirement on how to display it.  You may use below too, which will put the text in separate lines.  Just a suggestion. :-)
ccnum.PadLeft(txtCreditCard.Text.Length, 'X') + " <br/>Exp Date: " + ddExpirationMonth.SelectedItem.Text + " " + ddExpirationYear.SelectedItem.Text + " <br/>Card ID: " + txtCardID.Text;
0
 
1jawsAuthor Commented:
thank you soo much!!!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 7
  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now