Connecting Tech Pros Worldwide Forums | Help | Site Map

Control arrays

Newbie
 
Join Date: Oct 2008
Location: India
Posts: 19
#1: Oct 10 '08
i am new to vb.net......i have two radio buttons associated with msflexgrid version 6 in vb.net ..can any body help me out how can i create control array...In vb6.0 it was it was ** easy ....but i don't why MS decided to drop this facility from VB.net... In vb 6.0 it was like this

Expand|Select|Wrap|Line Numbers
  1.   Select Case Index
  2.             Case 0
  3.                 EntryOption = 0
  4.             Case 1
  5.                 EntryOption = 1
  6.         End Select
  7.  
  8.  
  9.    If EntryOption = 0 Then
  10.             ds = CurDb.OpenRecordset("PlinthBeamData", DAO.RecordsetTypeEnum.dbOpenDynaset)
  11.         Else
  12.             If EntryOption = 1 Then
  13.                 ds = CurDb.OpenRecordset("FloorBeamData", DAO.RecordsetTypeEnum.dbOpenDynaset)
  14.             End If

Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#2: Oct 10 '08

re: Control arrays


Well, you could drop the msflexgrid, and use one of the actual .NET components, that would make life a lot easier.

What exactly are you trying to make an array of? I saw no array code in the source code you posted. Just a poorly constructed CASE/IF statement.

Its very easy to make arrays in .NET:
Expand|Select|Wrap|Line Numbers
  1. Dim mycontrolarray As somecontrolType() = New somecontrolType(9) {} 
  2.  
None of those controls are instanciated yet, so you would have to say like:
Expand|Select|Wrap|Line Numbers
  1. mycontrolarray(0) = New somecontrolType() 
  2.  
As for why they dropped it, I'm still wondering why they continued VB at all :-P
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,137
#3: Oct 10 '08

re: Control arrays


Quote:

Originally Posted by Plater

As for why they dropped it, I'm still wondering why they continued VB at all :-P

You can't just get rid of something once it's been used for vast amounts of applications (even though I find myself wonder why VB was designed they way it was...)

Anyways, are you attempting to make an array based on the data retrieved from the record set?

I'm also confused as to how arrays fit into your question.

-Frinny
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#4: Oct 10 '08

re: Control arrays


Quote:

Originally Posted by Frinavale

You can't just get rid of something once it's been used for vast amounts of applications

Sure you can, its known as "progress". I'm wiping stuff out of my applications that I have had in for like 2years now, because I don't like it. Time for the axe.


Why not use this?
Expand|Select|Wrap|Line Numbers
  1. If Index =0 Then
  2.    ds = CurDb.OpenRecordset("PlinthBeamData", DAO.RecordsetTypeEnum.dbOpenDynaset) 
  3. ElseIf Index= 1 Then 
  4.    ds = CurDb.OpenRecordset("FloorBeamData", DAO.RecordsetTypeEnum.dbOpenDynaset) 
  5. End If 
  6.  
Newbie
 
Join Date: Oct 2008
Location: India
Posts: 19
#5: Oct 11 '08

re: Control arrays


Well....Thank u for replying........I can't drop msflex grid as i had used it in my whole project...n ...i don't understand when you say why are they continuing with Vb As far as i think VB is like Trynasouras Rex in the field of Languages.....I have two Radio buttons..i want when i click 1st option the data in the datagrid fits in the plinth beam table n when 2nd option is clicked data fits in Floorbeam table.....n code for both radio buttons is...
Expand|Select|Wrap|Line Numbers
  1.  Dim ds As DAO.Recordset
  2.  
  3.     Select Case Index
  4.             Case 0
  5.                 EntryOption = 0
  6.             Case 1
  7.                 EntryOption = 1
  8.         End Select
  9.         Data_Gr.Refresh()
  10.         Data_Gr.Row = 1
  11.         For i = 0 To 4
  12.             Data_Gr.Col = i
  13.             Data_Gr.Text = ""
  14.         Next
  15.         Data_Gr.Rows = 2
  16.         DataToGrid()
  17.         If EntryOption = 0 Then
  18.             ds = CurDb.OpenRecordset("PlinthBeamData", DAO.RecordsetTypeEnum.dbOpenDynaset)
  19.         Else
  20.             If EntryOption = 1 Then
  21.                 ds = CurDb.OpenRecordset("FloorBeamData", DAO.RecordsetTypeEnum.dbOpenDynaset)
  22.             End If
  23.         End If
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#6: Oct 13 '08

re: Control arrays


Ok, so when radiobutton1 is selected, do task1 and when radiobutton2 is selected do task2.
I'm not sure I still see any problem?


And yes, it is like the TRex, clumsy, partially-blind and short armed. But thats a personal opinion, hehe.
Newbie
 
Join Date: Oct 2008
Location: India
Posts: 19
#7: Oct 14 '08

re: Control arrays


Quote:

Originally Posted by Plater

Ok, so when radiobutton1 is selected, do task1 and when radiobutton2 is selected do task2.
I'm not sure I still see any problem?


And yes, it is like the TRex, clumsy, partially-blind and short armed. But thats a personal opinion, hehe.


Actually Data is going only in Plinth Table whether i select Ist option or 2nd option...this is my problem..n now it seems that i m going to pull my hair.....my codes are right but what is the prob i don't know.......

n also this short armed VB is vry dangerous....he he
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#8: Oct 14 '08

re: Control arrays


Unless radiobuttons are grouped together, they will each register a different value.
Are you sure that "Index" is ever changing in this code:
Expand|Select|Wrap|Line Numbers
  1. Select Case Index 
  2.             Case 0 
  3.                 EntryOption = 0 
  4.             Case 1 
  5.                 EntryOption = 1 
  6.         End Select 
  7.  
Have you set a breakpoint and stepped though your code?
Reply


Similar .NET Framework bytes