473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Value of type 'String' cannot be converted to '1-dimensional array of String'.


I get :Value of type 'String' cannot be converted to '1-dimensional array
of String' refering to curitem

Dim curItem As String

curItem = ListBox1.SelectedItem

TextBox1.Text = curItem

vcar = curItem

I had set up vcar above as in :

Friend vcar() As String

I freely admit to not knowing what I'm doing here; all my 20 yearsof
programming is seemingly worthless ....just trying to pass a variable from
one form to another and found myself with that error, which makes no sense
to me at all ...they are both strings, No ?
Nov 21 '05 #1
6 38043
When you declared vcar, you wrote it as: Friend vcar() As String when you
should have written: Friend vcar As String.

The difference is that parenthesis, which indicate that you want vcar to be
a String array (more than one value and therefore needing an index when
assigning values). So, when you wrote: vcar = curItem, you were, in
effect, saying "take this one text value from this textbox and make it be
the value of an array object".

Just take away the () on the vcar definition and you'll be all set.
"baret bonden" <ar****@networks-cc.com> wrote in message
news:2v*************@uni-berlin.de...

I get :Value of type 'String' cannot be converted to '1-dimensional array
of String' refering to curitem

Dim curItem As String

curItem = ListBox1.SelectedItem

TextBox1.Text = curItem

vcar = curItem

I had set up vcar above as in :

Friend vcar() As String

I freely admit to not knowing what I'm doing here; all my 20 yearsof
programming is seemingly worthless ....just trying to pass a variable from
one form to another and found myself with that error, which makes no sense
to me at all ...they are both strings, No ?

Nov 21 '05 #2

Użytkownik "baret bonden" <ar****@networks-cc.com> napisał w wiadomo¶ci
news:2v*************@uni-berlin.de...

I get :Value of type 'String' cannot be converted to '1-dimensional array
of String' refering to curitem

Dim curItem As String

curItem = ListBox1.SelectedItem

TextBox1.Text = curItem

vcar = curItem

I had set up vcar above as in :

Friend vcar() As String

I freely admit to not knowing what I'm doing here; all my 20 yearsof
programming is seemingly worthless ....just trying to pass a variable from
one form to another and found myself with that error, which makes no sense
to me at all ...they are both strings, No ?


vcar is an array of strings, so you have two options depending on what you
are trying to achieve:

1. Pass your string to the first element of vcar array:

Friend vcar(10) As String
vcar(0) = curItem

2. If you want an array where every element contains one char you should use
char array:

Dim vcar() As Char
vcar = curItem.ToCharArray

Hope that helps,
Maciek
Nov 21 '05 #3
Baret,

In addition to the others.

For some (probably compatible) reasons has Microsoft standard set Option
Strict and Option explicit to Off. As far as I know have all Regulars from
this newsgroup this set to On.

Either in the options as I do or every time in top of the files.

When you set those to On you will be warned for errors at runtime.

It can be harder because with you have to set yourself more.

You can compare it like this.

Behaviour en performance of VBNet
With option Strict On = C#
With option Strict Off = VB6

I hope this helps?

Cor

"baret bonden" <ar****@networks-cc.com>

I get :Value of type 'String' cannot be converted to '1-dimensional array
of String' refering to curitem

Dim curItem As String

curItem = ListBox1.SelectedItem

TextBox1.Text = curItem

vcar = curItem

I had set up vcar above as in :

Friend vcar() As String

I freely admit to not knowing what I'm doing here; all my 20 yearsof
programming is seemingly worthless ....just trying to pass a variable from
one form to another and found myself with that error, which makes no sense
to me at all ...they are both strings, No ?

Nov 21 '05 #4
Cor,

The default setting for Option Explicit in VB.NET is ON. Option Strict is,
by default, turned OFF.

You are right though, that it is best to have them both ON.

-Scott

"Cor Ligthert" <no************@planet.nl> wrote in message
news:u0*************@TK2MSFTNGP11.phx.gbl...
Baret,

In addition to the others.

For some (probably compatible) reasons has Microsoft standard set Option
Strict and Option explicit to Off. As far as I know have all Regulars from
this newsgroup this set to On.

Either in the options as I do or every time in top of the files.

When you set those to On you will be warned for errors at runtime.

It can be harder because with you have to set yourself more.

You can compare it like this.

Behaviour en performance of VBNet
With option Strict On = C#
With option Strict Off = VB6

I hope this helps?

Cor

"baret bonden" <ar****@networks-cc.com>

I get :Value of type 'String' cannot be converted to '1-dimensional
array
of String' refering to curitem

Dim curItem As String

curItem = ListBox1.SelectedItem

TextBox1.Text = curItem

vcar = curItem

I had set up vcar above as in :

Friend vcar() As String

I freely admit to not knowing what I'm doing here; all my 20 yearsof
programming is seemingly worthless ....just trying to pass a variable
from
one form to another and found myself with that error, which makes no
sense
to me at all ...they are both strings, No ?


Nov 21 '05 #5
Scott,

Thanks for correcting me. As I wrote I have set them on in the options so I
could not check that.

Cor

"Scott M." <s-***@nospam.nospam>
Cor,

The default setting for Option Explicit in VB.NET is ON. Option Strict
is, by default, turned OFF.

You are right though, that it is best to have them both ON.

-Scott

"Cor Ligthert" <no************@planet.nl> wrote in message
news:u0*************@TK2MSFTNGP11.phx.gbl...
Baret,

In addition to the others.

For some (probably compatible) reasons has Microsoft standard set Option
Strict and Option explicit to Off. As far as I know have all Regulars
from this newsgroup this set to On.

Either in the options as I do or every time in top of the files.

When you set those to On you will be warned for errors at runtime.

It can be harder because with you have to set yourself more.

You can compare it like this.

Behaviour en performance of VBNet
With option Strict On = C#
With option Strict Off = VB6

I hope this helps?

Cor

"baret bonden" <ar****@networks-cc.com>

I get :Value of type 'String' cannot be converted to '1-dimensional
array
of String' refering to curitem

Dim curItem As String

curItem = ListBox1.SelectedItem

TextBox1.Text = curItem

vcar = curItem

I had set up vcar above as in :

Friend vcar() As String

I freely admit to not knowing what I'm doing here; all my 20 yearsof
programming is seemingly worthless ....just trying to pass a variable
from
one form to another and found myself with that error, which makes no
sense
to me at all ...they are both strings, No ?



Nov 21 '05 #6
So far the only easy and pleasing thing about learning (trying to learn) VB
Net has been the kind support from this group. Many thanks.
"baret bonden" <ar****@networks-cc.com> wrote in message
news:2v*************@uni-berlin.de...

I get :Value of type 'String' cannot be converted to '1-dimensional array
of String' refering to curitem

Dim curItem As String

curItem = ListBox1.SelectedItem

TextBox1.Text = curItem

vcar = curItem

I had set up vcar above as in :

Friend vcar() As String

I freely admit to not knowing what I'm doing here; all my 20 yearsof
programming is seemingly worthless ....just trying to pass a variable from
one form to another and found myself with that error, which makes no sense
to me at all ...they are both strings, No ?

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Francois Grieu | last post by:
The values of ((int)0.7) and ((int)-0.7) seem to be 0 Is this independent of implementation ? TIA, François Grieu
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
11
by: tshad | last post by:
What is the best way to handle money in C#? Do you use float type? Then how do you handle rounding problems with cents as well as how best to display it? Thanks, Tom
0
by: Mike Schnorr | last post by:
I have a ASP.Net application that uses assemblies from several other solutions. When testing the applications on my machine I build all the referenced assemblies using nmake. The latest assemblies...
9
by: David | last post by:
I am getting the following error during run-time compilation or a rebuild all of my application: error BC30311: Value of type 'mynamespace.x' cannot be converted to 'mynamespace.x' This...
4
by: Barry | last post by:
object type cannot be converted to target type - i am getting this error message occuring numerous times in my task list, my project compiles and runs ok but it is a nuisance, I think Ihva eheard of...
2
by: Jim in Arizona | last post by:
I'm learning form an ASP.NET 1.0 book and I tried out some code that returns this error: Compiler Error Message: BC30311: Value of type 'Integer' cannot be converted to...
2
by: DraguVaso | last post by:
Hi, I'm getting in trouble with the Generic.List(Of T). When declaring a Shadoiws of Mybase.Add, I want to do some custom actions with the item, and cast it to another class. The problem is...
4
by: Mathieu Cartoixa | last post by:
Hi, I have been annoyed in one of my recent projects with a problem related to the explicit implementation of an interface on a value type. I will take an example to show the problem. Say we...
69
by: Horacius ReX | last post by:
Hi, I have the following program structure: main ..... int A=5; int* ptr= A; (so at this point ptr stores address of A) ..... .....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.