Asp.net - Multiple Lengths For Substring?
May 17, 2012
Can a substring have mutiple arguments? I am pulling a substring from a drop down list into my database for records, the string is between 6 and 8 numbers, is it possible to pass more than one argument to make this work?
Sample data:
DropDownList
123456 | Name
1234567 | Name
[Code]....
View 2 Replies
ADVERTISEMENT
Nov 18, 2010
I think this will be better than what I was thinking before.
How can I allow multiple lengths to a textbox.Allow multiple lengths on a textbox?
something like
if Not TextBox1.TextLength = 8 Or 11 Or 14 Or 18 Then msgbox("error")
View 5 Replies
Jan 17, 2012
I have 6 array lists and I would like to know which one is the longest without using a bunch of IF STATEMENTS."if arraylist.count > anotherlist.count Then...." <- Anyway to do this other than this?
Examples in VB.net or C#.Net (4.0) would be helpfull.
arraylist1.count
arraylist2.count
arraylist3.count
arraylist4.count
arraylist5.count
arraylist6.count
DIM longest As integer = the longest arraylist should be stored in this variable.
View 5 Replies
Oct 10, 2011
I'm trying to create a valid RegEx replacement pattern for correctly formatting specific .XML file names. Specifically, if a file name does not begin with a prefix, let's say, ACE_. If the XML file name and extension does not begin with ACE_, prepend the string ACE_ to the file name.For example, if my input source string is the following:
Widgets.xml
I would like to execute a single RegEx Replacement that would result in the string being:
ACE_Widgets.xml.
Conversely, if the string already begins with ACE_, I would like it to remain unchanged. Also,how can I include the pattern ".xml" to ensure that the string pattern for the file name and extension ends with ".xml" in the same matching pattern for the RegEx Replacement pattern? As for the match, I have some luck with the following:
^ACE_{1}[dD]+
Which indicates there is a match for the pattern if the input string is ACE_Widgets.xml and no match if the string is Widgets.xml
The RegEx pattern would suffice, but if you need to know the language in which I'd like to use the replacement pattern is in .NET 4.0 in either C# or VB.NET.
The following posting is close to what Im looking for, but with the inclusion of the *ix directory path prefix, and the use of preg_replace() in PHP, I'm having a bit of a struggle getting it to work with what I need to do:
Regular Expression: How to replace a string that does NOT start with something?
View 3 Replies
Feb 3, 2009
How will I select a substring with 2 criteria? I have a Richtextbox where I select a number after a : with this code; For Each line As String In Richtextbox1.Lines Dim equalsPos As Integer = line.IndexOf(":") + 1 txtFound.AppendText(line.Substring(equalsPos, line.Length - equalsPos)) Next This is working ok, but the whole line.length is appended for number2. The line ex. Some text:my number some text-my number2. I want my number appended to txtFound, and my number2 appended to txtFound2. With my code only number2 can be appended correct.
View 4 Replies
Apr 20, 2011
Forgive me but i have a noob question, I cant seem to get my head around.I have a textbox.text string as "111.1, 22.2, 3333.3, 444.44" What I want to is extract the numbers which may be random lengths, but all separated by a comma to
dim i1st number as Integer
dim i2nd number as Integer
dim i3rd number as Integer
dim i4th number as Integer
I know how to search for one instance of a string in a string but taking the 1st part to the comma, then the next comma and so on is confusing me.
[Code]...
View 2 Replies
Sep 3, 2010
Basically I'm just trying to see if the date/time of files have changed on files.So I've got code something like this:-
Dim fi_source_CreationTime As DateTime = fi.CreationTime
Dim file_info_DateCreated As String = '** LOADED from a file **
If (fi_source_CreationTime = CDate(file_info_DateCreated)) Then
[code]....
View 21 Replies
Apr 5, 2011
I'm working on a Pythagorean Theorem program that calculates the sides and angles of a right triangle. I have the side measurements and all that down, but I can't find the Visual Basic function that will allow me to calculate the angles from the side measurements. I've tried asin and sinh, but both give me the wrong measure.
View 2 Replies
May 9, 2011
simple loop code to split a text which is displayed on the text box. All that will need to do is split the text into 48 char lengths.
View 11 Replies
Apr 4, 2012
I have an array of strings such as "blue", "green", "red" and I wish to sort them so the longest string comes first and the shortest last.
Currently I am creating another array with the lengths of each string in the array in the same index positions and using this array as the key array to sort by as can be seen below, but I think this could be optimised into one line perhaps?
Dim colours() As string = {"blue", "green", "red"}
Dim colourslength() As Integer
For i As Integer = 0 To colours.Length - 1
[Code].....
Edit: just realised I defined colours as a list in the example code, it's an array in my actual code.
View 4 Replies
Feb 26, 2012
I am working on a project that I scroll from one screen to another.
A particular string I have 2 variables that can be changed. If I stay on this screen I can change either variable just as I need
however when I change to another screen then return my string is 1 digit longer and when I wish to edit this string my program fails because the string isn't the expected length.
A portion of my program follows....The Y6 is just a counter. The MA is a conditional control.
ElseIf _
Y6 = 4 _
And MA = True _
[Code]....
Delete 0-27 then determine whats there "NC" or "NO" and simply change it. But again when I leave this particular screen and return my text length is no longer 29 charactors long, it is now 30 charactors.
View 10 Replies
Jul 30, 2009
I want to write the DS into a txt fie with predefined field lengths.
Code:Dim ds As New Data.DataSetda.SelectCommand = New SqlCommand da.SelectCommand.Connection = conn da.SelectCommand.CommandText = "SELECT * from Samp1" da.Fill(ds, "S1")
[Code]...
View 8 Replies
Jan 1, 2011
Is there any way to create a multidinensional array that contains arrays of different lengths (similar to nesting arrays of different lengths in python).
Because if I were to declare a variable Dim accounts(2,2) As Integer all 1D arrays at each dimension have the same length. Is there any way to create an array so that this is not the case?
e.g The above code would create an array like this:
[[0,0],[0,0]]
but would it be possible to create this:
[[0,0],[0,0,0]]
View 3 Replies
Mar 27, 2012
I am working on a program that opens a .txt file, finds the length of each line in the file, and then outputs the minimum and maximum lengths. For example, assuming this is the .txt file I am opening:
2789304
293048203
27598493
[code].....
I would like to return something like this:
Minimum length: 6
Maximum length: 9
I cannot use arrays for this assignment. I figured out how to get the maximum length but cannot figure out how to get the minimum. Am I going about this the right way or is there an easier way to do this? Here is what I have thus far:
Dim FileName As String
Dim FileReader As StreamReader
Dim FileLine As String
[code].....
View 4 Replies
Feb 1, 2008
I have a string which can be of any length. I want to loop tthrough this string and if there 53 characters assign that to Variable1, then loop round again and assign the next 53 characters or less to variable2 etc etc until the end of the string. Ideally I would not want to split words - but that is another problem.....
View 10 Replies
Mar 25, 2009
For a school program, I was assigned to use a .dat file to store and edit information while using VB to be it's front end( to appear in a listbox). I was also given what field length to use per field. I never worked with .dat files, so I have a few questions (all the google-ing Ive done say the same thing: every .dat file is different so you can't play around with them):
[Code]...
View 4 Replies
Feb 3, 2011
I am trying to remove VB6 type code and use VB.Net code, in particular, remove "Left" and use "Substring". This code does not do what the old style code does. It seams to ignore the first two chars and forces the msgbox prompt no matter what I type in the textbox (at "Leave").
Private Sub TextBox5_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox5.Leave
If TextBox5.Text = "" Then
'Do nothing
[CODE]...
View 9 Replies
Oct 8, 2010
I'm getting an ArgumentOutOfRange error when using substring function in .NET. I'm new to .NET so probably doing something wrong. I have a txtField, which is a text field component in GUI. I'm using Microsoft Visual Basic 2010 Express
txtField.Substring(txtField.Length-4,txtField.Length-1)
If txt.Field contains only numberic values it works ok, but as soon as the text field contains characters it breaks.
View 1 Replies
Feb 7, 2011
I have a piece of code that I am using a for next statement and stepping through a string a little bit at a time. The problem is I get an error towards the end of my loop because my substring goes beyond the bounds of my string.
Dim Right As Integer = StartNumber.Value
Dim left As Integer = LengthNumber.Value
Dim i As Integer = 0
[code]....
Also my streamwriter is not writing to my file?
View 2 Replies
May 24, 2009
I have a string that contains a file location[code]..."
I want to get a substring of String 1 that does not contain the name of the actual file (e.g. "C:SomeDirectoryEntries")
View 2 Replies
Aug 10, 2011
Which one would you prefer to extract a sub-string from the given string and why?I am thinking that since Left and Right are VB functions and not .NET functions, they may cause problems in the future in terms of compatibility.
View 3 Replies
Jun 27, 2012
This question was resolved in C#, and I don't know how to do it in VB net. I want to search through a directory of files and see if my string is contained within any of the filenames. Then I just need a bolean answer if it exists or not. I know how to use the file.exists...this is not what I need. The link below is to the C# response. How to check if filename contains substring in C#
[Code]...
View 1 Replies
Feb 3, 2011
Example i have string =D:aaabddddd.jpg
string =D:aaabdddddfsdfsdfdd.jpg
i want to flexible sub string from right to ""
so answer=ddddd.jpg and dddddfsdfsdfdd.jpg
View 8 Replies
May 31, 2009
My problem is at SubString will do the job for me, but next string could look like this: 101OldGranny91222 So I can't determind the number - for the split - of char in the string, because it changes depending on there name etc.
View 4 Replies
Mar 7, 2011
Example : Dim t as string="My game is football"
How can i write flexible code substring word?So Result is
My
Game
Is
football
View 1 Replies
Apr 1, 2012
I have a text label, split half-and-half with a "/".label1.text = "I like dogs/I like cats"This will not be the same text (and not the same textlength)every times. I need to delete everything before the "/" with only a button. (for example, delete "I like dogs")
View 6 Replies
Oct 9, 2011
substring and the indexOf method
I have this problem that I'm going in circles on. The error message is "no accessible IndexOf can be called with these arguments."
My professor said that "to search for the string Los Angeles and substring will return it from the textbox, but it needs to know what position to start returning a word at, and that is where the IndexOf comes in." Does that mean substring and IndexOf are used together? That's what I did and may be the problem. Here's the code:
Private Sub btnOrder_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnOrder.Click
'Declare variables
[Code]....
View 1 Replies
May 4, 2010
I want to sort the binding source column (Product Code) which formatted like (AA-AAA AAA AAAA)
but i do not want straight sort on product code column, i want the sort as :
substring of 1,2 + 8,3 + 3,3 and then the rest of the column.
I know i can do it in the table direct using the OrderBy and the substring function, but the problem is that sort is not static it is dynamic according to different status means it change the substring order.
View 4 Replies
Aug 17, 2011
I am using ASP.NET with VB.NET. This is my code
[Code]...
I just want to trim the value to give me the 20.00 and convert it ToDouble End Result Must be 20.00 C# code will also help me undertand what needs to happen and why I am getting the error messsage Index and length must refer to a location within the string. Parameter name: length
View 7 Replies
Mar 5, 2010
I am working on a simple Point of Sale Program for my Intro to Visual Basic class. I am trying to pull a substring with a decimal point (ex 0009.50) from the string I get from my readline and turn it into a decimal value for calculating money values. Something is wrong with they way that I am converting and I can't find how to to it write in my book.
Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
Dim currentLine As String = String.Empty
[Code]....
View 7 Replies