473,698 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Select edItem

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 38069
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****@network s-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.Select edItem

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****@network s-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.Select edItem

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.ToCharA rray

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****@network s-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.Select edItem

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******** *****@TK2MSFTNG P11.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****@network s-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.Select edItem

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.nosp am>
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******** *****@TK2MSFTNG P11.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****@network s-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.Select edItem

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****@network s-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.Select edItem

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
3213
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
5126
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. And K&R2 mentions "signed extension" everywhere. Reading some old clc posts, I've beginning to realize that these books are over-generalizing the topic. I am just wondering what the difference between the following pairs of terms are: 1)...
11
14978
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
2079
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 get placed in a common directory that is referenced by my ASP.NET app. Occasionally I receive the following error: value of type "MyNamespace.MyClassName" cannot be converted to "MyNamespace.MyClassName" (there are a lot of these for different...
9
41950
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 occurs in only one component/project that accesses the 'x' object whereas several other components/projects also use the 'x' object in several other locations in exactly the same way without any problems. If I Rebuild
4
4173
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 this before but I cannot remember the solution, anybody got any help?
2
7207
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 'ASP.multiclasses_aspx.VehicleKey'. Source Error: Line 106:
2
8732
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 that I get the whole time this error: "value of type 'T' cannot be converted to 'clsBaseClass'". I get it with both CType and Directcast:
4
2375
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 have this simple interface : interface IInitializable { void Init();
69
3312
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
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.