VB.net increment in label through button click, -


please me code.

private sub button_click(byval sender object, byval e system.eventargs) handles button.click  dim cmd new oledbcommand cmd.commandtype = commandtype.text cmd.connection = cnn cmd.command.text ="select max (receipt_no) [cash_register]" cnn.open() dim string = convert.tostring(cmd.executescalar()) cnn.close() label.text = + 1 end sub 

i'm using ms access database, if last receipt_no "abc00004" in particular table ("abc00001,abc00002,abc00003,abc00004"). if click button next receipt_no "abc00005" show in label.text.

you should remove non numeric part of result, convert numeric part real number , perform increment, rebuild string non numeric part , required number of leading zero

so following example variable equal "abc00004"

dim = "abc00004" dim n = convert.toint32(v.substring(3)) + 1 = string.format("{0}{1:d5}", v.substring(0,3), n) 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -