C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Object reference not set to an instance of an object.


Posted Date: 22 Jul 2008      Total Responses: 5

Posted By: kali raj       Member Level: Gold     Points: 1



In Windows Application (VB.NET) I Have created a form and insert the datas its updated fine..
But wen i set property autoscroll = true to the Form That time error ll come...
That Error "Object reference not set to an instance of an object." came





Responses

Author: UltimateRengan    22 Jul 2008Member Level: DiamondRating:     Points: 0

post your code

UltimateRengan
nathan.rengan@gmail.com
Trichy-Rider Group



Author: kali raj    22 Jul 2008Member Level: GoldRating:     Points: 6

Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Windows.Forms
Imports System.Resources

Module Module1

Public con As OleDbConnection

Dim nlist() As Control
Structure qa
Dim question As String
Dim answer As String
Dim CtlType As String
End Structure
Structure qa1

Dim qa1 As String

End Structure
Public Sub setParent(ByRef frm As Form)
frm.MdiParent = MDIParent1
End Sub

Structure ordlist
Public top As Integer
Public ord As Integer
End Structure
Public Sub intialize()
If IsNothing(con) = True Then
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "c:\kali\emr\pedi.mdb;")
con.Open()
End If
End Sub
Public Sub clearform(ByVal f As Form)
Dim temp As Control, rb As RadioButton, cb As CheckBox, i As Int16, tb As TextBox, cb1 As ComboBox
Dim ptemp As Control, p As Panel
For Each ptemp In f.Controls
If LCase(ptemp.GetType().ToString) = "system.windows.forms.panel" Then
p = ptemp

For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.radiobutton" Then
rb = temp
rb.Checked = False
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.checkbox" Then

cb = temp
cb.Checked = False




ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.textbox" Then

tb = temp
tb.Text = ""
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.combobox" Then
cb1 = temp
cb1.Text = ""
End If
Next
End If
Next
End Sub

Public Sub readform(ByVal f As Form)
Dim st As String
Dim z
Dim rb As RadioButton
Dim cmd2 As OleDbCommand
Dim dr1 As OleDbDataReader
Dim sadapter As OleDbDataAdapter
Dim ds As DataSet

clearform(f)
st = "Select * from development1 where ssn='" & Patient.txtSSN.Text & "' and development='" & f.Controls("Label1").Text & "' ORDER BY development1.order"
cmd2 = New OleDbCommand(st, con)
sadapter = New OleDbDataAdapter(cmd2)
ds = New DataSet("tab")
sadapter.Fill(ds)
sortcontrols(f)


For z = 0 To ds.Tables(0).Rows.Count - 1

SetValue(ds.Tables(0).Rows(z).Item("Answer").ToString, nlist(ds.Tables(0).Rows(z).Item("order")), ds.Tables(0).Rows(z).Item("ControlType").ToString)


Next

End Sub
Public Function findcontrol(ByVal st1 As String, ByVal p As Panel) As Button
Dim temp As Control
For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.button" Then
If LCase(temp.Text) = LCase(st1) Then
findcontrol = temp
temp.Enabled = Not temp.Enabled 'True
End If
End If
Next
End Function
Public Function refresh(ByVal st1 As String, ByVal p As Panel) As Button
Dim temp As Control
For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.button" Then
If LCase(temp.Text) = LCase(st1) Then
refresh = temp
temp.Enabled = temp.Enabled = True
End If
End If
Next
End Function



Private Sub SetValue(ByVal st1 As String, ByVal p As Panel, ByVal ctltype As String)
Dim temp As Control, rb As RadioButton, cb As CheckBox, i As Int16, tb As TextBox, cb1 As ComboBox
Dim chkvalue() As String

If UCase(ctltype) = "CHECKBOX" Then chkvalue = st1.Split("^")

For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.radiobutton" Then
If LCase(temp.Text) = LCase(st1) Then
rb = temp
rb.Checked = True
Exit For
End If
If LCase(temp.Tag) = LCase(st1) Then
rb = temp
rb.Checked = True
Exit For
End If
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.checkbox" Then
For i = 0 To UBound(chkvalue)
If LCase(temp.Text) = LCase(chkvalue(i)) Then
cb = temp
cb.Checked = True
Exit For
End If
If LCase(temp.Tag) = LCase(chkvalue(i)) Then
cb = temp
cb.Checked = True
Exit For
End If
Next
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.textbox" Then

tb = temp
tb.Text = st1
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.combobox" Then

cb1 = temp
cb1.Text = st1
End If
Next
End Sub
Private Sub sortcontrols(ByVal f As Form)
Dim c As Control
Dim clist() As Control
Dim ordl() As ordlist
Dim z, z0
Dim i = 0
Dim topl() As Integer

If f.Controls.Count > 0 Then
For Each c In f.Controls
If LCase(c.GetType().ToString) = "system.windows.forms.panel" Then
i = i + 1
ReDim Preserve clist(i)
ReDim Preserve ordl(i)
ReDim Preserve topl(i)
clist(i) = c
ordl(i).ord = i
ordl(i).top = c.Top
topl(i) = c.Top
End If
Next

Array.Sort(topl)
For z0 = 1 To i
For z = 1 To i
If topl(z0) = clist(z).Top Then
ReDim Preserve nlist(z0)
nlist(z0) = clist(z)
End If
Next
Next
End If
For z0 = 1 To i
' MsgBox(nlist(z0).Name)
Next

End Sub

Public Sub insertrecord(ByVal f As Form)
sortcontrols(f)
Dim cmd3 As OleDbCommand = New OleDbCommand
Dim st3, res As String
Dim z
Dim rbt As RadioButton, tempqa As qa, ctl As Control
Dim tempqa1 As qa1
st3 = "delete from development1 where ssn='" & Patient.txtSSN.Text & "' and development='" & f.Controls("Label1").Text & "'"
cmd3.CommandText = st3
cmd3.Connection = con
cmd3.ExecuteNonQuery()

For z = 1 To UBound(nlist)
If IsNothing(findselectedcontrol(nlist(z))) = True Then
GoTo 15
Else
End If
ctl = findselectedcontrol(nlist(z))
tempqa = findqa(nlist(z))
st3 = "insert into development1 values('" & f.Controls("Label1").Text & "','" & z & "','" & tempqa.CtlType & "','" & Patient.txtSSN.Text & "','" & tempqa.question & "','" & tempqa.answer & "')"
cmd3.CommandText = st3
cmd3.Connection = con
cmd3.ExecuteNonQuery()

If f.Controls("label1").Text = "Lead Questionnaire" Or f.Controls("label1").Text = "TB Questionnaire" Then
res = res + " " + tempqa.question + vbCrLf + vbTab + tempqa.answer + vbCrLf
Else
res = res + " " + tempqa.question + ":" + tempqa.answer + " "

End If

15: Next


setPhysicalSummary()




'If f.Controls("label1").Text = "Lead Questionnaire" Or f.Controls("label1").Text = "TB Questionnaire" Then
' st3 = "delete from Questionnaire where ssn='" & Patient.txtSSN.Text & "' and form ='" & f.Controls("Label1").Text & "'"
' cmd3.CommandText = st3
' cmd3.Connection = con
' cmd3.ExecuteNonQuery()
' st3 = "insert into Questionnaire values('" & f.Controls("Label1").Text & "','" & Patient.txtSSN.Text & "','" & res & "')"
' cmd3.CommandText = st3
' cmd3.Connection = con
' cmd3.ExecuteNonQuery()
'Else


' st3 = "delete from dialogs where ssn='" & Patient.txtSSN.Text & "' and form ='" & f.Controls("Label1").Text & "'"
' cmd3.CommandText = st3
' cmd3.Connection = con
' cmd3.ExecuteNonQuery()
' st3 = "insert into dialogs values('" & f.Controls("Label1").Text & "','" & Patient.txtSSN.Text & "','" & res & "')"
' cmd3.CommandText = st3
' cmd3.Connection = con
' cmd3.ExecuteNonQuery()
'End If
MsgBox("Updated Successfully")

End Sub
Public Sub setPhysicalSummary()
Dim cmd, cmd1 As OleDbCommand, dr, dr1 As OleDbDataReader
Dim name, res1, result As String

Physical.rtbSummary.Text = ""
cmd = New OleDbCommand("select distinct development from phyquery where ssn='" & Patient.txtSSN.Text & "' ", con)
dr = cmd.ExecuteReader

While (dr.Read)
cmd1 = New OleDbCommand("select * from phyquery where ssn='" & Patient.txtSSN.Text & "' and development = '" & dr("development").ToString & "' ", con)
dr1 = cmd1.ExecuteReader
res1 = ""
While (dr1.Read)
res1 = res1 + " ; " + dr1("question").ToString + " " + dr1("answer").ToString

End While
name = "<" + dr("development").ToString + ">" + vbNewLine
result = result + vbNewLine + name + res1

End While


Physical.rtbSummary.Text = result

cmd = New OleDbCommand("select distinct development from phyquery where ssn='" & Patient.txtSSN.Text & "' ", con)
dr = cmd.ExecuteReader
While (dr.Read)
Physical.bold(dr(0).ToString)
End While
Physical.save()
End Sub
Public Sub setnormal(ByVal dev, ByVal ssn)

Dim sqlstr, st3 As String
Dim com As OleDbCommand = New OleDbCommand
st3 = "delete from development1 where ssn='" & ssn & "' and development='" & dev & "'"
com.CommandText = st3
com.Connection = con
com.ExecuteNonQuery()
sqlstr = "INSERT INTO development1 ( development, [order], ControlType, Question, Answer,ssn ) SELECT PhysicalsNormal.development, PhysicalsNormal.order, PhysicalsNormal.ControlType, PhysicalsNormal.Question, PhysicalsNormal.Answer,'" & ssn & "' FROM(PhysicalsNormal) WHERE (((PhysicalsNormal.ssn)='normalphy') AND ((PhysicalsNormal.development)='" & dev & "'))"
com.CommandText = sqlstr
com.Connection = con
com.ExecuteNonQuery()
MsgBox("Normal Values Assigned")
setPhysicalSummary()
End Sub

Function findselectedcontrol(ByVal p As Panel) As Control
Dim temp As Control
Dim rb As RadioButton, cb As CheckBox, tb As TextBox, cb1 As ComboBox
Dim finres As Control = Nothing
For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.radiobutton" Then
rb = temp
If rb.Checked = True Then
finres = rb
Exit For
End If
End If
If LCase(temp.GetType().ToString) = "system.windows.forms.checkbox" Then
cb = temp
If cb.Checked = True Then
finres = cb
End If
End If
If LCase(temp.GetType().ToString) = "system.windows.forms.textbox" Then
tb = temp

finres = tb
End If
If LCase(temp.GetType().ToString) = "system.windows.forms.combobox" Then
cb1 = temp

finres = cb1
End If
Next

findselectedcontrol = finres
End Function
Function findqa(ByVal p As Panel) As qa
Dim temp As Control
Dim res As RadioButton
Dim templabel As Label
Dim temptext As TextBox
Dim tempcombo As ComboBox
Dim chkbox As CheckBox

Dim finres As RadioButton = Nothing
Dim tempqa As qa

tempqa.answer = ""

For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.radiobutton" Then
res = temp
If res.Checked = True Then
finres = res
If res.Tag = "" Then
tempqa.CtlType = "RadioButton"
tempqa.answer = res.Text
Exit For
Else
tempqa.CtlType = "RadioButton"
tempqa.answer = res.Tag
Exit For
End If



End If
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.checkbox" Then
chkbox = temp
If chkbox.Checked = True Then
If tempqa.answer = "" Then
tempqa.answer = chkbox.Text
tempqa.CtlType = "Checkbox"
Else
tempqa.answer = tempqa.answer & "^" & chkbox.Text
tempqa.CtlType = "Checkbox"
End If

End If

ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.textbox" Then
temptext = temp
tempqa.answer = temptext.Text

tempqa.CtlType = "TextBox"


ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.combobox" Then
tempcombo = temp
tempqa.answer = tempcombo.Text



tempqa.CtlType = "ComboBox"
End If


Next

For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.label" Then
templabel = temp
If templabel.Tag = "-" Then
tempqa.question = ""
Exit For
Else
tempqa.question = templabel.Text
Exit For
End If

End If
Next

findqa = tempqa

End Function

End Module
this is my code..here am using module.........



Author: venkatesan    22 Jul 2008Member Level: DiamondRating:     Points: 2

Check whether u have passed any null value

else

post ur code and mention which line u got Error?

Thanks



Wish u a Very Happy New Year
Regards,
M.Venkatesan.

Please remember to Rate “Excellent or Good or Poor”



Author: kali raj    22 Jul 2008Member Level: GoldRating:     Points: 6

Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Windows.Forms
Imports System.Resources

Module Module1

Public con As OleDbConnection

Dim nlist() As Control
Structure qa
Dim question As String
Dim answer As String
Dim CtlType As String
End Structure
Structure qa1

Dim qa1 As String

End Structure
Public Sub setParent(ByRef frm As Form)
frm.MdiParent = MDIParent1
End Sub

Structure ordlist
Public top As Integer
Public ord As Integer
End Structure
Public Sub intialize()
If IsNothing(con) = True Then
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "c:\kali\emr\pedi.mdb;")
con.Open()
End If
End Sub
Public Sub clearform(ByVal f As Form)
Dim temp As Control, rb As RadioButton, cb As CheckBox, i As Int16, tb As TextBox, cb1 As ComboBox
Dim ptemp As Control, p As Panel
For Each ptemp In f.Controls
If LCase(ptemp.GetType().ToString) = "system.windows.forms.panel" Then
p = ptemp

For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.radiobutton" Then
rb = temp
rb.Checked = False
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.checkbox" Then

cb = temp
cb.Checked = False




ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.textbox" Then

tb = temp
tb.Text = ""
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.combobox" Then
cb1 = temp
cb1.Text = ""
End If
Next
End If
Next
End Sub

Public Sub readform(ByVal f As Form)
Dim st As String
Dim z
Dim rb As RadioButton
Dim cmd2 As OleDbCommand
Dim dr1 As OleDbDataReader
Dim sadapter As OleDbDataAdapter
Dim ds As DataSet

clearform(f)
st = "Select * from development1 where ssn='" & Patient.txtSSN.Text & "' and development='" & f.Controls("Label1").Text & "' ORDER BY development1.order"
cmd2 = New OleDbCommand(st, con)
sadapter = New OleDbDataAdapter(cmd2)
ds = New DataSet("tab")
sadapter.Fill(ds)
sortcontrols(f)


For z = 0 To ds.Tables(0).Rows.Count - 1

SetValue(ds.Tables(0).Rows(z).Item("Answer").ToString, nlist(ds.Tables(0).Rows(z).Item("order")), ds.Tables(0).Rows(z).Item("ControlType").ToString)


Next

End Sub
Public Function findcontrol(ByVal st1 As String, ByVal p As Panel) As Button
Dim temp As Control
For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.button" Then
If LCase(temp.Text) = LCase(st1) Then
findcontrol = temp
temp.Enabled = Not temp.Enabled 'True
End If
End If
Next
End Function
Public Function refresh(ByVal st1 As String, ByVal p As Panel) As Button
Dim temp As Control
For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.button" Then
If LCase(temp.Text) = LCase(st1) Then
refresh = temp
temp.Enabled = temp.Enabled = True
End If
End If
Next
End Function



Private Sub SetValue(ByVal st1 As String, ByVal p As Panel, ByVal ctltype As String)
Dim temp As Control, rb As RadioButton, cb As CheckBox, i As Int16, tb As TextBox, cb1 As ComboBox
Dim chkvalue() As String

If UCase(ctltype) = "CHECKBOX" Then chkvalue = st1.Split("^")

For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.radiobutton" Then
If LCase(temp.Text) = LCase(st1) Then
rb = temp
rb.Checked = True
Exit For
End If
If LCase(temp.Tag) = LCase(st1) Then
rb = temp
rb.Checked = True
Exit For
End If
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.checkbox" Then
For i = 0 To UBound(chkvalue)
If LCase(temp.Text) = LCase(chkvalue(i)) Then
cb = temp
cb.Checked = True
Exit For
End If
If LCase(temp.Tag) = LCase(chkvalue(i)) Then
cb = temp
cb.Checked = True
Exit For
End If
Next
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.textbox" Then

tb = temp
tb.Text = st1
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.combobox" Then

cb1 = temp
cb1.Text = st1
End If
Next
End Sub
Private Sub sortcontrols(ByVal f As Form)
Dim c As Control
Dim clist() As Control
Dim ordl() As ordlist
Dim z, z0
Dim i = 0
Dim topl() As Integer

If f.Controls.Count > 0 Then
For Each c In f.Controls
If LCase(c.GetType().ToString) = "system.windows.forms.panel" Then
i = i + 1
ReDim Preserve clist(i)
ReDim Preserve ordl(i)
ReDim Preserve topl(i)
clist(i) = c
ordl(i).ord = i
ordl(i).top = c.Top
topl(i) = c.Top
End If
Next

Array.Sort(topl)
For z0 = 1 To i
For z = 1 To i
If topl(z0) = clist(z).Top Then
ReDim Preserve nlist(z0)
nlist(z0) = clist(z)
End If
Next
Next
End If
For z0 = 1 To i
' MsgBox(nlist(z0).Name)
Next

End Sub

Public Sub insertrecord(ByVal f As Form)
sortcontrols(f)
Dim cmd3 As OleDbCommand = New OleDbCommand
Dim st3, res As String
Dim z
Dim rbt As RadioButton, tempqa As qa, ctl As Control
Dim tempqa1 As qa1
st3 = "delete from development1 where ssn='" & Patient.txtSSN.Text & "' and development='" & f.Controls("Label1").Text & "'"
cmd3.CommandText = st3
cmd3.Connection = con
cmd3.ExecuteNonQuery()

For z = 1 To UBound(nlist)
If IsNothing(findselectedcontrol(nlist(z))) = True Then
GoTo 15
Else
End If
ctl = findselectedcontrol(nlist(z))
tempqa = findqa(nlist(z))
st3 = "insert into development1 values('" & f.Controls("Label1").Text & "','" & z & "','" & tempqa.CtlType & "','" & Patient.txtSSN.Text & "','" & tempqa.question & "','" & tempqa.answer & "')"
cmd3.CommandText = st3
cmd3.Connection = con
cmd3.ExecuteNonQuery()

If f.Controls("label1").Text = "Lead Questionnaire" Or f.Controls("label1").Text = "TB Questionnaire" Then
res = res + " " + tempqa.question + vbCrLf + vbTab + tempqa.answer + vbCrLf
Else
res = res + " " + tempqa.question + ":" + tempqa.answer + " "

End If

15: Next


setPhysicalSummary()




'If f.Controls("label1").Text = "Lead Questionnaire" Or f.Controls("label1").Text = "TB Questionnaire" Then
' st3 = "delete from Questionnaire where ssn='" & Patient.txtSSN.Text & "' and form ='" & f.Controls("Label1").Text & "'"
' cmd3.CommandText = st3
' cmd3.Connection = con
' cmd3.ExecuteNonQuery()
' st3 = "insert into Questionnaire values('" & f.Controls("Label1").Text & "','" & Patient.txtSSN.Text & "','" & res & "')"
' cmd3.CommandText = st3
' cmd3.Connection = con
' cmd3.ExecuteNonQuery()
'Else


' st3 = "delete from dialogs where ssn='" & Patient.txtSSN.Text & "' and form ='" & f.Controls("Label1").Text & "'"
' cmd3.CommandText = st3
' cmd3.Connection = con
' cmd3.ExecuteNonQuery()
' st3 = "insert into dialogs values('" & f.Controls("Label1").Text & "','" & Patient.txtSSN.Text & "','" & res & "')"
' cmd3.CommandText = st3
' cmd3.Connection = con
' cmd3.ExecuteNonQuery()
'End If
MsgBox("Updated Successfully")

End Sub
Public Sub setPhysicalSummary()
Dim cmd, cmd1 As OleDbCommand, dr, dr1 As OleDbDataReader
Dim name, res1, result As String

Physical.rtbSummary.Text = ""
cmd = New OleDbCommand("select distinct development from phyquery where ssn='" & Patient.txtSSN.Text & "' ", con)
dr = cmd.ExecuteReader

While (dr.Read)
cmd1 = New OleDbCommand("select * from phyquery where ssn='" & Patient.txtSSN.Text & "' and development = '" & dr("development").ToString & "' ", con)
dr1 = cmd1.ExecuteReader
res1 = ""
While (dr1.Read)
res1 = res1 + " ; " + dr1("question").ToString + " " + dr1("answer").ToString

End While
name = "<" + dr("development").ToString + ">" + vbNewLine
result = result + vbNewLine + name + res1

End While


Physical.rtbSummary.Text = result

cmd = New OleDbCommand("select distinct development from phyquery where ssn='" & Patient.txtSSN.Text & "' ", con)
dr = cmd.ExecuteReader
While (dr.Read)
Physical.bold(dr(0).ToString)
End While
Physical.save()
End Sub
Public Sub setnormal(ByVal dev, ByVal ssn)

Dim sqlstr, st3 As String
Dim com As OleDbCommand = New OleDbCommand
st3 = "delete from development1 where ssn='" & ssn & "' and development='" & dev & "'"
com.CommandText = st3
com.Connection = con
com.ExecuteNonQuery()
sqlstr = "INSERT INTO development1 ( development, [order], ControlType, Question, Answer,ssn ) SELECT PhysicalsNormal.development, PhysicalsNormal.order, PhysicalsNormal.ControlType, PhysicalsNormal.Question, PhysicalsNormal.Answer,'" & ssn & "' FROM(PhysicalsNormal) WHERE (((PhysicalsNormal.ssn)='normalphy') AND ((PhysicalsNormal.development)='" & dev & "'))"
com.CommandText = sqlstr
com.Connection = con
com.ExecuteNonQuery()
MsgBox("Normal Values Assigned")
setPhysicalSummary()
End Sub

Function findselectedcontrol(ByVal p As Panel) As Control
Dim temp As Control
Dim rb As RadioButton, cb As CheckBox, tb As TextBox, cb1 As ComboBox
Dim finres As Control = Nothing
For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.radiobutton" Then
rb = temp
If rb.Checked = True Then
finres = rb
Exit For
End If
End If
If LCase(temp.GetType().ToString) = "system.windows.forms.checkbox" Then
cb = temp
If cb.Checked = True Then
finres = cb
End If
End If
If LCase(temp.GetType().ToString) = "system.windows.forms.textbox" Then
tb = temp

finres = tb
End If
If LCase(temp.GetType().ToString) = "system.windows.forms.combobox" Then
cb1 = temp

finres = cb1
End If
Next

findselectedcontrol = finres
End Function
Function findqa(ByVal p As Panel) As qa
Dim temp As Control
Dim res As RadioButton
Dim templabel As Label
Dim temptext As TextBox
Dim tempcombo As ComboBox
Dim chkbox As CheckBox

Dim finres As RadioButton = Nothing
Dim tempqa As qa

tempqa.answer = ""

For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.radiobutton" Then
res = temp
If res.Checked = True Then
finres = res
If res.Tag = "" Then
tempqa.CtlType = "RadioButton"
tempqa.answer = res.Text
Exit For
Else
tempqa.CtlType = "RadioButton"
tempqa.answer = res.Tag
Exit For
End If



End If
ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.checkbox" Then
chkbox = temp
If chkbox.Checked = True Then
If tempqa.answer = "" Then
tempqa.answer = chkbox.Text
tempqa.CtlType = "Checkbox"
Else
tempqa.answer = tempqa.answer & "^" & chkbox.Text
tempqa.CtlType = "Checkbox"
End If

End If

ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.textbox" Then
temptext = temp
tempqa.answer = temptext.Text

tempqa.CtlType = "TextBox"


ElseIf LCase(temp.GetType().ToString) = "system.windows.forms.combobox" Then
tempcombo = temp
tempqa.answer = tempcombo.Text



tempqa.CtlType = "ComboBox"
End If


Next

For Each temp In p.Controls
If LCase(temp.GetType().ToString) = "system.windows.forms.label" Then
templabel = temp
If templabel.Tag = "-" Then
tempqa.question = ""
Exit For
Else
tempqa.question = templabel.Text
Exit For
End If

End If
Next

findqa = tempqa

End Function

End Module




Author: lavanya    22 Jul 2008Member Level: GoldRating:     Points: 0

post your error message in detail.


Post Reply
You must Sign In to post a response.
Next : Recuring billing
Previous : To PravennPandey
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use