if statement - If in if in vb.net -
im making webbrowser , when press enter in textbox want see if there domain in there , if navigate url in textbox
this i've done right now
if e.keycode = keys.enter if textbox1.text.contains(".com") or textbox1.text.contains(".se") or textbox1.text.contains(".net") or textbox1.text.contains(".org") or textbox1.text.contains(".au") or textbox1.text.contains(".ws") or textbox1.text.contains(".co") or textbox1.text.contains(".biz") or textbox1.text.contains(".tv") or textbox1.text.contains(".info") or textbox1.text.contains(".int") or textbox1.text.contains(".gov") or textbox1.text.contains(".mil") or textbox1.text.contains(".dk") or textbox1.text.contains(".ac") or textbox1.text.contains(".ad") or textbox1.text.contains(".ae") or textbox1.text.contains(".af") or textbox1.text.contains(".ag") or textbox1.text.contains(".ai") or textbox1.text.contains(".au") or textbox1.text.contains(".an") or textbox1.text.contains(".at") or textbox1.text.contains(".eu") or textbox1.text.contains(".ax") or textbox1.text.contains(".ca") or textbox1.text.contains(".de") or textbox1.text.contains(".fi") or textbox1.text.contains(".gb") or textbox1.text.contains(".is") or textbox1.text.contains(".nz") or textbox1.text.contains(".us") or textbox1.text.contains(".uk") try webcontrol1.source = new uri(textbox1.text) catch ex exception end try end if end if
not sure issue you're having, here's 1 way accomplish you're doing:
private sub textbox1_keyup(sender object, e system.windows.forms.keyeventargs) handles textbox1.keyup if e.keycode = keys.enter if isurl(me.textbox1.text) webcontrol1.source = new uri(if(not me.textbox1.text.startswith("http://", stringcomparison.invariantcultureignorecase), "http://", "") & me.textbox1.text) end if end if end sub private function isurl(byval url string) boolean dim valid boolean = false dim exts() string = split(".com;.se;.net;.org;.au;.ws;.co;.biz;.tv;.info;.int;.gov;.mil;.dk;.ac;.ad;.ae;.af;.ag;.ai;.au;.an;.at;.eu;.ax;.ca;.de;.fi;.gb;.is;.nz;.us;.uk", ";") each ext in exts if url.endswith(ext, stringcomparison.invariantcultureignorecase) valid = true exit end if next return valid end function
Comments
Post a Comment