2
Answers

Send values from Class file to VB form in vb.net windows application 2005

venkii R

venkii R

13y
6.3k
1
Hi All,
Currently i am working on Windows Application in VB.NET. i have 10 class files. so i created induvidual classes. only 1 main vb form and it's have some lables. i pass dataset to class file and maipulation will done in class file.

Main form:

If State = "AP" Then
gAP_State.AssignRules(gDsData)
ElseIf State = "MH" Then
gMHState.AssignRules(gDsData)
ElseIf State = "MP" Then
gMPState.AssignRules(gDsData)
ElseIf State = "KA" Then
gKAState.AssignRules(gDsData)
End If

Class File: gMHState

Public Function AssignRules(ByVal gDsData As DataSet) As Boolean

For i = 0 To gDsData.Tables(0).Rows.Count - 1

Dim chlForm As New Extraction_Main

chlForm.lblExtractedCount.Text = gDsData.Tables(0).Rows.Count

chlForm.lblStateIdValue.Text = gDsData.Tables(0).Rows(i)(StateID).ToString()

End Function

from the above code in main form i have Dataset. i need to pass this to class file and iterate it and Assign some rules and save in DB. in this class file i created Main form object and i needs to show in main form Lable. same way needs to show the StateID which is processed currently in StateID Lable. if dataset having 10 rows then my StateID lable in main form will show the 10 Ids 1 by 1 based on transaction.

but from my above code its not shown corresponding values in Main form lables.

Can any one plz send the code or give the idea how can i achive this.?

Awaiting for response.

Regards,
Venky


Answers (2)
0
venkii R

venkii R

NA 13 19k 13y
Hi Hirendra,

Thnx for ur quick reply. i think u didn't get what i need actually. i want to populate data in Main vb form lables from what ever data i get it in Dataset row by row while updation.

this updation will occur in class file and Dataset values also get in Class file only. i wiant to populate lables in Main VB form. for each row there will be separate CityID and City Zip code. i need to populate these two values in lables.

Regards,
Venkii
0
Hirendra Sisodiya

Hirendra Sisodiya

237 8.1k 4.6m 13y
hello V

try this code

Public

Function AssignRules(ByVal gDsData As DataSet) As Boolean




For i = 0 To gDsData.Tables(0).Rows.Count - 1
For Each frm As Windows.Forms.Form In Application.OpenForms
If frm.Name = "Extraction_Main" Then

frm.lblExtractedCount.Text = gDsData.Tables(0).Rows.Count

frm.lblStateIdValue.Text = gDsData.Tables(0).Rows(i)(StateID).ToString()


Exit For


End If


Next


Next


End Function

please mark as answer if it helps