473,566 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add prefix to arry of string

3 New Member
Hello,
I'm new to VB, and I realy don't get the arrays. I have to write a program that takes an arry of string as a parameter and adds "sir" to each string. I need to use "get upper bound."
Can anyone help? I'm desperate, I tried eveything and nothing works.
Aug 27 '06 #1
5 3257
wappy
8 New Member
how about this... :)

Private Sub AddPrefixToArra y(ByRef arr() As String)
Dim i As Integer
For i = 1 To UBound(arr)
arr(i - 1) = "Sir " & Trim(arr(i - 1))
Next i
End Sub
Aug 27 '06 #2
abfab
3 New Member
Hi,
I did try and Its still not working, I can not get it to display anything in the listbox, Thank you for your help.
:confused:

Private Sub Button1_Click(. .....ByVal e ....) Handles Button1.Click

Dim List() As String = {"", "Kill", "Zav", "SAV", "Jan"}
ListBox1.Items. Clear()
ListBox1.Items. Add(AddTitle)
End Sub

Private Sub AddTitle(ByRef arr() As String)
Dim i As Integer
For i = 1 To UBound(arr)
arr(i - 1) = "Sir " & Trim(arr(i - 1))
Next i
End Sub
Aug 27 '06 #3
wappy
8 New Member
TRY THIS..........

Private Sub Command1_Click( )
Dim arr(4) As String

arr(0) = ""
arr(1) = "Kill"
arr(2) = "Zav"
arr(3) = "SAV"
arr(4) = "Jan"

AddTitle arr

End Sub

Private Sub AddTitle(ByRef arr() As String)
Dim i As Integer
ListBox1.Clear
For i = 1 To UBound(arr)
ListBox1.AddIte m "Sir " & Trim(arr(i - 1))
Next i
ListBox1.AddIte m ""
ListBox1.AddIte m "ENJOY CODIN :)"
End Sub
Aug 28 '06 #4
wappy
8 New Member
you shouldnt put a procedure name on listbox.additem since the syntax only requires a variable or a string value, besides sub procedures doesnt return a value, use functions instead of procedures it will work then.
Aug 28 '06 #5
abfab
3 New Member
Thank you so much,
I got it, this realy works.


Private Sub Button1_Click Handles Button1.Click
Dim arr() As String = {"", "Kill", "Zav", "SAV", "Jan"}

AddTitle(arr)

End Sub


Private Sub AddTitle(ByRef arr() As String)
Dim add As String = ("Sir. ")
Dim i As Integer
ListBox1.Items. Clear()
For i = 1 To arr.GetUpperBou nd(0)
ListBox1.Items. Add(add & Trim(arr(i)))
Next i
End Sub
Aug 29 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2418
by: Doug Farrell | last post by:
Hi everyone, I'm trying to build a program to interface to a SOAP/XML interface provided by one of our vendors. This interface is built with MS SOAP Toolkit 3.0, so I'm guessig they are running a .NET server. I'm trying to build my program with Python as I've got to deploy on both Linux and Sun/Solaris platforms. I'm developing on RedHat...
6
5477
by: nico | last post by:
In my python scripts, I use a lot of accented characters as I work in french. In order to do this, I put the line # -*- coding: UTF-8 -*- at the beginning of the script file. Then, when I need to store accented characters in a string, I used to prefix the literal string with 'u', like this: mystring = u"prénom" But if I understand well,...
4
3896
by: Zenon | last post by:
I am attempting to append a string prefix to a report field which is based on a query result. I want the user to be able click a checkbox on the form which opens the report to determine whether the string is appended or not. I see that this can be done in the properties of the field, but I cannot figure out if it can be done with VB code. ...
6
5733
by: Gilles Nambert | last post by:
Hi, I come form VB and i'm used to Redim statement to modifiy the size of an arry dunamically, keeping his content, and i dont't find how to do this simple operation in C# ? Thanks and best regards Gilles
3
1938
by: Coffee | last post by:
I have asked this before, but the offered solution did not work. I want to have a command button, that transfers any text from a textbox to a variable which is an array. so that i can print out single letters of the text. e.g. if i have "hello" in the textbox and i print out the forth letter it should list "l".... can someone tell me howto?
2
18721
by: james.cssa | last post by:
I want to declare namespace prefix in the Envelope element (i.e. xmlns:xsi and xmlns:xsd) so that the document will be serialized to look like the following. However, I don't know the right way to do that in Java. <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'...
2
21530
by: scottpet | last post by:
Hi, I want to add a namespace prefix to the root node of an object I am serializing to XML. I have been reading though this article: http://msdn2.microsoft.com/en-gb/library/system.xml.serialization.xmlnamespacedeclarationsattribute.aspx I get namespace prefixes in the document, but not on the root node. Specifically, the serializer...
11
5157
by: cjt22 | last post by:
Hi startswith( prefix]) States: Return True if string starts with the prefix, otherwise return False. prefix can also be a tuple of suffixes to look for. However when I try and add a tuple of suffixes I get the following error: Type Error: expected a character buffer object
0
853
by: hermitking | last post by:
Hi I need a way to load a text file in to an arry the way i got it working is just gives me 1 leter of the word beacuse i have it pick a radom number to get the variable.
0
7584
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...
0
8108
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
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...
0
7951
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...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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...
0
5213
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...
0
3643
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.