vb.net - Change textbox value dynamically? -



vb.net - Change textbox value dynamically? -

i have 7 textboxes named lblsun, lblmon etc , 7 buttons named cmdsun, cmdmon etc. want alter text value of these text boxes , buttons within query. i've tried me.controls("cmd" & daysofweek(i)).text, not work.

the error object reference not set instance of object.

here code:

public sub loadschedule() ' days of week dim daysofweek(0 6) string dim integer dim var string dim ctrl command ' set days of week daysofweek(0) = "sun" daysofweek(1) = "mon" daysofweek(2) = "tue" daysofweek(3) = "wed" daysofweek(4) = "thu" daysofweek(5) = "fri" daysofweek(6) = "sat" ' connect db dim con oledb.oledbconnection = new oledb.oledbconnection(form1.constring) con.open() ' query stuff dim query string dim cmd new oledb.oledbcommand dim rs oledb.oledbdatareader ' loop = lbound(daysofweek) ubound(daysofweek) ' set query query = "select * schedule employee=" & employee & " , scheduleday='" & daysofweek(i) & "'" cmd = new oledb.oledbcommand(query, con) rs = cmd.executereader() ' var var = "cmd" & daysofweek(i) ' results? if rs.hasrows = true ' rs.read() ' show babe 'controls("lbl" & daysofweek(i)).text = rs.item("timein") & " - " & rs.item("timeout") me.controls("cmd" & daysofweek(i) & "").text = "edit" else ' show babe controls("lbl" & daysofweek(i)).text = "rdo" controls("cmd" & daysofweek(i)).text = "new" end if next ' close db con.close() end sub

can help me? doing wrong?

you trying access controls in me.controls don't exist, because buttons/textboxes within table.

you should utilize :

table.controls("cmd" & daysofweek(i)).text = "edit"

vb.net variables dynamic

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -