String() Variable In VB?
Aug 24, 2010
I'm trying to modify a program where there is a variable that stores all the specified file types in a String() variable. What I would like to do is to somehow append to this variable in any way if I want to search another directory or just grab another individual file.
//Grab files from a directory with the *.txt or *.log as specified in the Combo Box
Dim strFiles As String()
strFiles = System.IO.Directory.GetFiles(txtSource.Text, cmbtype.SelectedItem, IO.SearchOption.AllDirectories)
EDIT: Edited to include code snippet used.
Dim strFiles As String()
Dim listFiles As List(Of String)(strFiles)
If (cmbtype.SelectedItem = "All") Then
[code]....
View 2 Replies
ADVERTISEMENT
Nov 18, 2009
I'm looking for a way to search a string variable for two words and copy the text in between them into another variable. This needs to be done as many times as the match occurs.
View 3 Replies
Jun 2, 2011
Say I have something like this
Dim Level1 as Integer = 83
Dim Goal as String
Goal = InputBox(" What level is your goal?")
[code].....
View 7 Replies
Apr 4, 2009
I am trying to insert a string variable inside of two strings, and make a combined string. Public Sub Page_Load() Dim Id As String Id = Trim (Request.QueryString("Id")) End Sub Dim mp3text as string url... & Id & ".mp3" My goal is to make the mp3text variable have a string that is: url...(If Id is 7) It is for some reason not connecting up correctly. I checked what string it is outputting and this is what it is giving: url...It is missing the Id content.
View 12 Replies
Feb 9, 2011
The code below works for the class that I hard coded "XCCustomers" in my RetrieveIDandName method where I use CType. However, I would like to be able to pass in various classes and property names to get the integer and string LIST returned. For example, in my code below, I would like to also pass in "XCEmployees" to my RetrieveIDandName method. I feel so close... I was hoping someone knew how to use CType where I can pass in the class name as a string variable.
Note, all the other examples I have seen and tried fail because we are using Option Strict On which disallows late binding. That is why I need to use CType.I also studied the "Activator.CreateInstance" code examples to try to get the class reference instance by string name but I was unable to get CType to work with that.When I use obj.GetType.Name or obj.GetType.FullName in place of the "XCCustomers" in CType(obj, XCCustomers)(i)I get the error "Type 'obj.GetType.Name' is not defined" or "Type 'obj.GetType.FullName' is not defined"
'+++++++++++++++++++++++++++++++
Imports DataLaasXC.Business
Imports DataLaasXC.Utilities
[code]....
View 2 Replies
Dec 5, 2011
These is the content of my txt file which is saved in D drive in my pc abc,1,2,3..I tried the flowing but it didn't work:[code]I am getting error on this line.. data = line.Split(","c)...it says this line isn't in use anymore or something and that I rather use LineInput but thats asks for filenumber and i don't know what that is. I am sorry but I am a complete beginner. what else can I try? [code]ok that error is gone now but now if I want to add these values to a list box..how can i do that?
View 1 Replies
May 30, 2012
I have a List(of String()). I have written a custom comparer (implements IComparer(of string)) to do an alphanumeric sort.Is there a way to sort the List using a given index to determine which position in the String() to sort by? In other words one time I might sort by Index = 0 and another time by Index = 3. The length of all String() in the list is the same.For reference this question is similar to Sort List<String[]> except I am using VB.net and that question is hardwired to Index=0.
EDIT from OP's comments:I started simple with the non custom comparer but I am getting an error: expression does not produce a value. Not sure what I am doing wrong.Here is the code:
Public Shared Function SortListOfStringArray(ByVal ListOfStringArray As List(Of String()), ByVal SortByIndex As Integer) As List(Of String())
Return ListOfStringArray.Sort(Function(x, y) x(SortByIndex).CompareTo(y(SortByIndex)))
End Function
View 1 Replies
Oct 2, 2009
just found out that replace(string does not do the same as string.replace when my string variable was an empty str the first one returns "nothing" and the second returns an empty string (as expected).just sloppy coding anyhow, it was a function that was converted from classic asp and never rewritten properly. [code]
View 1 Replies
Apr 12, 2009
I am using the MODI DLL (Microsoft Office Document Imaging) because it has an OCR engine. That's working fine, but I'm having trouble capturing the resulting text into my own string variable (weird, huh). Modi has the result stored in the following Modi string variable:
img.Layout.Text
I've tried three ways to capture this value, only one of them works (not the one that I need to work)
(1) Dim txt as string = img.Layout.Text 'fails
(2) MsgBox(img.Layout.Text) 'fails
(3) M = new Msg(img.Layout.Text) 'succeeds
Method 3 (the only one working) is a custom msgbox I built in VB.Net, and it accepts a regular .Net string variable. I need Method-1 to work. The error thrown is this:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt." I even tried it like this:
(1) Dim txt as string = img.Layout.Text.ToString.Trim
Here's the complete code:
Dim doc As New MODI.Document
doc.Create("C:VCR.tif")
Dim img As MODI.Image
[Code].....
View 4 Replies
Apr 18, 2011
how can I replace all string in string variable like
dim str = "I am testing and testing and testing"
After replace with "and"
ReplaceAll(str,"and","or")
How can I replace all with case insentive not case sensative?
View 3 Replies
Sep 29, 2009
I am not sure how I would do this or if it is possible. I am looking to manipulate a variable.For example if myVariable = " Apples" I would like to take a user input and make it "Apples and Bananas" or whatever the user entry is.
View 11 Replies
Sep 12, 2011
I have a string variable, the variable could contain error or not. i want to know how can i set like a flag to the variable if the variable value has error or not. something like:
[Code]...
View 5 Replies
Nov 1, 2011
've done some searching but can't get my head around how I would use a string as a variable name. So something like....
Dim a as string = "something here"
Dim b as string = "a"
msgbox var[b]
[code].....
View 3 Replies
Sep 19, 2009
In my code I would like to put together a string and then pass that string as the name of a variable to a function. For instances, in the following code, if the value of a3 equals "row1" then mySub(object) uses the values in the variable row1. How do I do this?
Dim a1 As String
Dim a2 As String
Dim a3 As String
[Code].....
View 9 Replies
Jul 25, 2005
How do I use a value of a string as a public variable name/object that I can then change....dim var1 as integerdim var2 as integerdim var3 as integer...ect...Dim vroot as string = "var"Dim i as integer = 1Dovar + i.tostring'this returns "var1"'now how do i use this var1 returned value to act like a variable??i=i+1loop until i = 15Also how would i do this with objects....say i had a series of labels named label1, labe2, label3...ect... to call these through a "label + i.tostring + .text" script also.....
View 12 Replies
Dec 13, 2011
If I try to put a string into a Boolean variable such as this:
Dim testValue As String = "True"
Dim bool1 As Boolean = testValue
With Option Strict On I get an error and the suggested fix is to change the second line to:
Dim bool1 As Boolean = CBool(testValue)
This is fine, But - what are the advantages / disadvantages of doing this instead:
Dim bool1 As Boolean = Boolean.Parse(testValue)
View 4 Replies
Feb 10, 2011
Using VB.6, I am trying to assigning a value to a string variable but it causes an error. I am doing that in following way:
Dim a As Variant
a = "<div style="width: 400px;"><img title=""
View 5 Replies
Nov 9, 2009
sRndMessageNumber = "sNewMessage" & CInt(Int((3 - 1 + 1) * Rnd() + 1))
I want to Calculate a number between 1 to 3 and then call the variable sNewMessage2 for example. So how to convert from string to variable?
View 3 Replies
Dec 7, 2010
What i am trying to do is this:
Dim Name as string
Name = "Bob"
Dim Name.tostring as Integer
Which will create as variable called Bob of type integer.
But obviously this code doesn't work. So what is the real way to do this if it can be done?
View 2 Replies
Mar 29, 2012
if this silly but I am trying to declare a string variable by the following line
[Code]...
View 2 Replies
Feb 23, 2010
this is my code -
for i as integer = 0 to rows.count - 1
output &= "Name =" & row(i)("Name")
output &= "lastName =" & row(i)("lastName")
[Code]....
is there a way to make a for loop and run applicant 1,2,3,4.... in one shot?
View 3 Replies
Oct 28, 2009
Right now me filling a combobox by this way.
[Code]...
By this way combobox CmbId is storing above sql query ouput. But now i want to get above query ("Select Name from StudentDetails where Id=10 ") result to store in a variable string. How can i do this ?
View 3 Replies
Apr 4, 2009
How to set a variable to the value of a string from an INI File.
MY INI File contents
[General]
PlayerLogin=
PlayerFullName=
PlayerPassword=
PlayerStatus=enabled
PlayerIsMuted=0
[Code] .....
I am creating a free game.
View 3 Replies
Sep 14, 2011
Well my other post didn't get accepted in the past hour so I'm assuming I asked something wrong?? No clue.
Anyway I have variable
propertyCode
which can equal R or B
The program I'm running opens a text file to run a GetData routine
I need to know how I can, keep the R in the text file, but have it display as a word when I run the program.
View 2 Replies
Feb 3, 2011
Is it possible to use a string as an array? I mean: I have several arrays
Dim a10() As Integer = {530}
Dim a15() As Integer = {370, 231}
Dim a20() As Integer = {305, 176, 126}
'I declare a variable as a string and I assign the name of an array to it
Dim tablaalfa As String = "a10"
'I retrieve data from the array using the name of the variable instead:
lbl1.Text = tablaalfa(2)
View 9 Replies
Apr 21, 2011
I'm going to describe what I'm trying to do and then what I'm doing in hopes of making this as clear as possible.I'm trying to create a way of having data avaialble to the application that could be changed in the future and not have to recompile the code.Normally I do this for my connection strings incase something changes, this way I can just change the file and I'm good.however in this case I'm trying to store a long string variable that contains something like(including all " in the string) "Dear " + emailRecp + vbCrLf + "Thank you for buying our product...."
Now when I do this as part of the code with something like strMessage = "Dear " + emailRecp + vbCrLf + "Thank you for buying our product...."when I look at the output from this it looks like (which is what I want):
Dear Mr Smith
Thank you for buying our product....
however when I do strMessage = My.Settings.purchaseMessage (even with .ToString()) the output looks like Dear " + emailRecp + vbCrLf "Thank you for buying our product....how to do this in another manner that won't affect performance.I have also tried to trim the " from the first and last char positions and no luck.
View 5 Replies
Jun 18, 2012
i like to assign html codes to String variable
Dim code As String
code= " <meta http-equiv="Content-Type" content="text/html; charset=windows-1254"> "
i think i am getting this error because of double Quotation marks "character constant must contain exactly one character."how can i assign it to a string?
View 4 Replies
Jan 31, 2010
sgBox("********" + Microsoft.VisualBasic.Right(f, Len(f) - Len(vFilepath)) + " | File so ignored | " + i) where i is an integer, f and vFilepath are strings but I get the following message:Conversion from string "********~$SwitchSellReport - 230" to type 'Double' is not valid.All I want to do is put the number that is in i on the end of the string.
View 5 Replies
Aug 16, 2011
Is it possible to use a string for string 2? cuz whenever i tried it would return a 0 instead of the position of the string. however when i hard code the string into the code it works
View 7 Replies
Aug 23, 2011
I have got the following
PHP MsgBox("********" + Microsoft.VisualBasic.Right(f, Len(f) - Len(vFilepath)) + " | File opened so ignored | " + i)
where i is an integer, f and vFilepath are strings but I get the following message:
Conversion from string "********~$SwitchSellReport - 230" to type 'Double' is not valid.
All I want to do is put the number that is in i on the end of the string.
View 2 Replies