7 Replies - 754 Views - Last Post: 30 August 2009 - 08:36 AM Rate Topic: -----

#1 gshanouda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-August 09

conver list box control from vb6 to vb.net

Post icon  Posted 23 August 2009 - 10:23 AM

How to convert the following line from vb 6 to vb.net

input14name = Me.lstminput.List(13)


When I use the following line
input14name = me.lstminput.items.item(13)


and the item in the location 13 does not contain any value I am getting a compile error

I need your help please
thanks in advance

This post has been edited by gshanouda: 23 August 2009 - 10:28 AM

Is This A Good Question/Topic? 0
  • +

Replies To: conver list box control from vb6 to vb.net

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: conver list box control from vb6 to vb.net

Posted 23 August 2009 - 10:42 AM

Moved to VB.NET

Here's some information on the VB.NET ListBox control :)
Was This Post Helpful? 0
  • +
  • -

#3 danny_kay1710  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 28
  • View blog
  • Posts: 358
  • Joined: 27-April 08

Re: conver list box control from vb6 to vb.net

Posted 23 August 2009 - 11:10 AM

That conversion is correct as far as I can tell.

What is the compile error?

If it is "InvalidArgument=Value of '13' is not valid for 'item'" or similar then it is simply because you don't have an item in the 13th index. You will have to re-arrange the code to avoid specifically referencing item 13 if your not 100% sure it will always be there.

Remember that the index 13 refers to the 14 item, if you don't have 14 items the code will error.

EDIT: Spelling

This post has been edited by danny_kay1710: 23 August 2009 - 11:14 AM

Was This Post Helpful? 0
  • +
  • -

#4 gshanouda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-August 09

Re: conver list box control from vb6 to vb.net

Posted 23 August 2009 - 12:00 PM

View PostPsychoCoder, on 23 Aug, 2009 - 09:42 AM, said:

Moved to VB.NET

Here's some information on the VB.NET ListBox control :)


I actually moved to VB.net and I need help converting the codes from vb6 to vb.net
Was This Post Helpful? 0
  • +
  • -

#5 gshanouda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-August 09

Re: conver list box control from vb6 to vb.net

Posted 30 August 2009 - 08:10 AM

View Postdanny_kay1710, on 23 Aug, 2009 - 10:10 AM, said:

That conversion is correct as far as I can tell.

What is the compile error?

If it is "InvalidArgument=Value of '13' is not valid for 'item'" or similar then it is simply because you don't have an item in the 13th index. You will have to re-arrange the code to avoid specifically referencing item 13 if your not 100% sure it will always be there.

Remember that the index 13 refers to the 14 item, if you don't have 14 items the code will error.

EDIT: Spelling


that is exactuly the error I am getting; however, my list box is set to have a maximum of 15 items; however, they may not be there all the time. I need to pass a validation check all the time or what to assign the variable to the items.

please help.
Was This Post Helpful? 0
  • +
  • -

#6 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2241
  • View blog
  • Posts: 9,412
  • Joined: 29-May 08

Re: conver list box control from vb6 to vb.net

Posted 30 August 2009 - 08:21 AM

Collections in vb.net start at 0 not 1.

Quote

I need to pass a validation check all the time or what to assign the variable to the items.

Its always a good idea to check that index is within the bound on the collection.
If Index < 0 OR Index>Listbox.count-1 Then Throw OutOfBoundsException

This post has been edited by AdamSpeight2008: 30 August 2009 - 08:26 AM

Was This Post Helpful? 0
  • +
  • -

#7 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 372
  • Joined: 17-July 09

Re: conver list box control from vb6 to vb.net

Posted 30 August 2009 - 08:23 AM

You could try an IF/Else statements to check if the item is there first.

This post has been edited by PDUNZ: 30 August 2009 - 08:26 AM

Was This Post Helpful? 0
  • +
  • -

#8 gshanouda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-August 09

Re: conver list box control from vb6 to vb.net

Posted 30 August 2009 - 08:36 AM

View PostPDUNZ, on 30 Aug, 2009 - 07:23 AM, said:

You could try an IF/Else statements to check if the item is there first.


How can I add your validation to my codes:

[code]

If flagcycle = 1 Then
Dim input1name
Dim input2name
Dim input3name
Dim input4name
Dim input5name
Dim input6name
Dim input7name
Dim input8name
Dim input9name
Dim input10name
Dim input11name
Dim input12name
Dim input13name
Dim input14name
Dim input15name
Dim input1command
Dim input2command
Dim inputdelay

input1name = Me.lstminput.items.Item(0)
input2name = Me.lstminput.Items.Item(1)
input3name = Me.lstminput.Items.Item(2)
input4name = Me.lstminput.Items.Item(3)
input5name = Me.lstminput.Items.Item(4)
input6name = Me.lstminput.Items.Item(5)
input7name = Me.lstminput.Items.Item(6)
input8name = Me.lstminput.Items.Item(7)
input9name = Me.lstminput.Items.Item(8)
input10name = Me.lstminput.Items.Item(9)
input11name = Me.lstminput.Items.Item(10)
input12name = Me.lstminput.Items.Item(11)
input13name = Me.lstminput.Items.Item(12)
input14name = Me.lstminput.Items.Item(13)
input15name = Me.lstminput.Items.Item(14)

input1command = Me.txtmnextinput.Text
input2command = Me.txtmprevinput.Text
inputdelay = Me.txtinputdelay3.Text


If input2name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input3name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input4name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input5name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input4name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input6name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input4name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input5name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input7name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input4name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input5name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input6name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input8name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input4name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input5name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input6name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input7name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input9name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input4name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input5name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input6name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input7name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input8name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input10name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input4name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input5name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input6name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input7name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input8name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input9name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input11name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input4name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input5name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input6name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input7name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input8name & "</INPUT>" & vbCrLf & _
" " & "<INPUT>" & input9name & "</INPUT>" & _
vbCrLf & " " & "<INPUT>" & input10name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input12name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input4name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input5name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input6name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input7name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input8name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input9name & "</INPUT>" & _
vbCrLf & " " & "<INPUT>" & input10name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input11name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input13name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInput State Input</NAME>" & vbCrLf & " " & "<INPUTDELAY>" & inputdelay & "</INPUTDELAY>" & vbCrLf & " " & "<INPUT>" & input1name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input2name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input3name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input4name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input5name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input6name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input7name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input8name & "</INPUT>" & vbCrLf & _
" " & "<INPUT>" & input9name & "</INPUT>" & _
vbCrLf & " " & "<INPUT>" & input10name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input11name & "</INPUT>" & vbCrLf & " " & "<INPUT>" & input12name & "</INPUT>" & _
vbCrLf & " " & "<NEXTINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input2command & "</IRPRESSACTION>" & vbCrLf & " " & "</NEXTINPUT>" & vbCrLf & " " & "<PREVINPUT>" & vbCrLf & " " & "<IRPRESSACTION>" & input1command & "</IRPRESSACTION>" & vbCrLf & " " & "</PREVINPUT>" & _
vbCrLf & " " & "</FEATURE>"

ElseIf input14name = Nothing Then
Me.txtxmlout.Text = " " & "<FEATURE StateType=" & """" & "Relative" & """" & ">" & vbCrLf & " " & "<NAME>MultiInpu
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1