VS 2010 Variable From Two Strings?
Oct 17, 2010Public Class Form1
Public tc1 = Color.Blue
Public tc2 = Color.Green
[code].....
Public Class Form1
Public tc1 = Color.Blue
Public tc2 = Color.Green
[code].....
I'm creating a method to replace variables in strings, I'm going to share an example of how I'm replacing values and can see short falls in how what I'm doing. Here's a stripped down example of what I'm doing. It replaces a variable with the date specified, so %today(-1) would give me yesterday, %today(2) would give me two days from now.
[Code]...
Is there an easy way to find a certain string within a string and then return the strings that you find as an array?I have written this:
Public Function FindStrings(ByVal strSourceString As String, ByVal strStartString As String, ByVal strEndString As String) As String()
Dim StringStartposition As Integer
Dim StringEndPosition As Integer
Dim Currentposition As Integer = 1
[Code]...
I have this string called time. It's value is in this format: HH:MM:SS The numbers change, but the format stays the same. I want to separtate the code into 3 strings Hour, Minutes, Seconds.
View 2 RepliesQuote:
I have been working on a homework assignment and I am having problems with it. Okay here is my final code. I declare a variable that is not used yet. I am wondering if I need to use the index to somehow fix this issue with the consonants. Maybe I need to nest another if, then or do some kind of comparison to figure out if the word begins with a consonant then tell it to move the consonants to the end
'you know something like this below, but this is not my final code yet:
determine if origninalWord begins with a consonant
determine how many consonants there are before you reach the first vowel
If originalWord begins with 1 consonant
[CODE]...
But I do not know the proper way to code the begining in red color text the last two sections work for vowels and numbers. Here is my new code.
Code:
'Gail Amalfitano
'date modified: April 1,2,4,5,6 (date created 3/27/09)
'This program is for converting words or strings to pig latin. The user enters what they want converted,'hits the converter button and views the pig latin version of their entry.
Option Explicit On
Option Strict On
Option Infer Off
[CODE]...
Quote:
Say I have a List(Of Tag) with Tag being an object. One member of Tag, Tag.Description, is a string, and I want to make a comma-separated concatenation of the Description members.Is there an easier way to do this than to read the Description members into a List(Of String) and then use the Join function?
View 2 RepliesSay that i have the following code that parse about 20k records from the DB.
Code #1
vb.net While reader.Read()
list.Add(If(Integer.TryParse(reader(0).ToString, 0), Integer.Parse(reader(0).ToString), 0))
End While
And then another code which does the very same thing but it seems to be a little cleaner.
Code #2
vb.net While reader.Read()
Dim storeowner As Integer = 0
Integer.TryParse(reader(0).ToString, storeowner)
list.Add(storeowner)
End While
This is what i am confused about; does the compiler creates a new variable automatically when i use the if statement without strictly declared variable? What approach is better in sense of performance?
Say I have something like this
Dim Level1 as Integer = 83
Dim Goal as String
Goal = InputBox(" What level is your goal?")
[code].....
Is there a way to use strings in Enums like the example below:
Enum myEnum
val1 = "some string 1"
val2 = "some string 2"
val3 = "some string etc"
End Enum
It seems like you can only use integers for the underlying values.
I guess my question has two parts:
1. My program has to read text out of a text file. I use some HTML tags to preserve the formatting. For example, I might have the line "this is a <b> line </b> of <b> text </b>" where "line" and "text" are bold. How do I make it so the string prints to a RichtextBox, but only "line" and "text" are bold? I would use a RichTextbox.SaveFile method, but the program works by reading a group of richtextboxes in a flowlayoutpanel and appending them to a single text file.
2. How would I extract the text from between two strings? For instance, I have created special tags for use in my program. These tags tell the program where to add controls. Say my string was:
"[IMG= "dog.jpg" /] this is a picture of a dog. [IMG= "cat.jpg"] this is a picture of a cat."
For each occurrence of the string "[IMG=", I would need it to find the corresponding "/]" and extract the text between the two. I could maybe do something with a substring function. I don't know.
how do i concatenate strings? i have done it like this.
[Code]...
If INPUT = "Fog/Mist" Or "Overcast Haze" Or "Freezing Fog" Or "Shallow Fog" Or "Partial Fog" Or "Patches of Fog" Or "Fog in Vicinity" Or "Freezing Fog in Vicinity" Or "Shallow Fog in Vicinity" Or "Partial Fog in Vicinity" Or "Patches of Fog in Vicinity" Or "Showers
[code].....
Forgive me for the total noobness of the question which follows. I am preparing something extremely simple for a project at work. This part involves generation of new names, for stuff like Stone Bridge, Farmer Grove Hunters Meadow. You need a first name and a last name, which would be two sets of strings, say, 20 items each. Last time I wrote VB code, around VB3, I would have written
[Code]....
I'm new in this forum, and I'm a very very very basic user of the VB. How can I create a list of strings? I'm trying to make a chat with a robot. I put 2 labels. And my code is:
Dim mylist As New List(Of String)
mylist = "hello", "bye"
If Not Label1.Text = mylist Then
[code].....
I want to be able to use a loop and reference controls using a string. The following code works for textboxes.
dim myControl as Control
dim ControlName as string
dim LoopCount as Integer
For LoopCount = 1 to 3
[code].....
i have a list of strings
Public baseList As New List(Of String)
That I fill with a list of base words, but I now need to build a new list of words in which will contain a list of every combination of words in the baseList (given that each string is less than the maximum length i specify)For Example if baseList contains
horse
at
ten
football
and the maximum string length is set to 10, the finalList would contain
horse
horseat
horseten
horseatten
[code]....
how to build finalList from baseList?
it is possible to create objects from strings.Supose I have a class Matrix with a Row(x) property and an array S = {"One","Two"}. Can i do something like this in vb.net?
For i = 0 To 1Dim S(i) = New MatrixNext i
Dim P As String() = One.Row(0)
'Which gives me the first row of Matrix One How can I create objects similar to this?
My goal is actually very simple: I simply want a (shared) function that accepts a List(Of String) which creates an image and writes those strings (line by line) onto the image. There's a bit more to it than that, but for the sake of example this is all you need to know.Usually when drawing on an image I would create a Bitmap object and get the graphics object from Graphics.FromImage:
Dim bmp As New Bitmap(100, 100)
Using g As Graphics = Graphics.FromImage(bmp)
g.FillRectangle(...)
[code]....
Seems easy enough, but the problem is that I don't know how many strings there will be in the list, nor how long they will be. The image should 'scale itself' according to the strings in the list. If the list contains 5 strings it should be 5 strings high (plus a little extra for borders). If the list contains only 1 string it should be only one string high. Same goes for the width, if the longest string is 150 pixels, the image needs to be at least 150 pixels (160, 170 or something).
This is all good, I can get the dimensions of the strings by using Graphics.MeasureString. The problem now is that I need the dimensions of the image to create the bitmap. I need the Graphics object to get the dimensions. But, I need the bitmap to get the Graphics object I'm stuck in a loop here, if I don't have the Graphics object (I can't create it from nothing..) then I cannot measure the strings, but if I cannot measure the strings then I cannot determine how large my image will be, so I cannot create a bitmap and associated Graphics object...
I would like to make an enum of strings. There are several masks for text boxes that I would like to standardize in our system.For simplicity lets say there are 2 masks:
"PhoneNumber" which is "(999)000-0000"
"Zip Code" which is "00000-9999"
I would like to be able to reference these through out the entire program in a manner such as:
DefaultMasks.ZipCode or DefaultMasks.PhoneNumber
Since enums can not be of string type, what would your best suggestions be as to how I could do this. I had thought about a class with constants in it but I was not sure how to implement that properly.
This is related to my last question.Even though Access considers Nulls and zero-length strings (ZLS) separate values, often developers wish to treat them as equivalent for the sake of an If...Then statement or some other stretch of code. One way to accomplish this is to write code like this:
' Not so efficient
If IsNull(varAge) or varAge = "" Then
' do something
[code].....
Ok, so say the string is: <a href "[URL]">abc</a> And I just want to get the text "abc" from between the <a href "[URL]"> and the </a>. How would I do so? I dont think I can use the split function, can I?
View 9 RepliesI want to get a string between 2 strings using Regex.The the string I have is "<b>hello</b>", now I want to get the string between <b> and </b>. I guess its something like Regex(String, "<b>(.+)</b>" but I'm not sure how to do it. I know there is this function called GetBetween but I guess this is a better way.
View 9 RepliesI have an string in a textfile that looks like this:or something similar. The T's represent true and the F's represent false. I wrote each letter to an array, like so:
[Code]...
I'm populating a datagridview from a database where all the data has had apostrophes and quotation marks stripped out and replaced with ASCII values; now I want to replace them back. Since the user can perform a variety of queries that are all displayed in the same table, any column might contain text fields.
View 9 RepliesThis is in a RichTextBox. I'm making a string of sports stats and I need to have them aligned neatly in the RichTextBox. Here is an example: str = "12/24 (tab) 225 yards (tab) 2 TDs (tab) 2 INTs" When I use the vbTab constant in place of (tab) I run into problems as the size of the text in each column can be different which makes the tab not balance out correctly.
[Code]...
i have a program where im trying to split a string from 1 text box and output the values in to 2 different text boxes .
my string username: password which reside in txt1.text
i want to split the string at ":" and have username appear in txt2.text and password appear in txt3.text i have this code but doesn't work for what i want to do.
Quote:
Dim text Array() As String = txt1.text.Split(":"c)
'ALPHA SORT THE ARRAY
Array.Sort(text Array)
[code]....
Also trying to find a way to rejoin the text back to the original string afterward in the username: password format
what is the easiest way to step through a string in this manner... I want to have my program look for one keyword and then another.. in otherwords it needs to find "hello56" and THEN find the word "bob" there are so many places the word "bob" is but I need to locate the "bob" thats after "hello56" Hope this example is clear.
[Code]...
Ok so I have a 3 fields in a webBrowser that my bot will need to fill. 1st field is the City: 2nd is the Place Name: 3rd is the Street Address: Here is an example of my addresses:
~1Cafe~2 ~322 Queen st.~4 ~5Toronto~6 So for the city I will need to fill it with all the text in between ~5 and ~6. Right now this is what I have
[Code]...
Quite simple but I'm having the hardest times trying to write something that'll do what I want. I have 1 listbox with 3 pre-defined strings each in their own index. I'm trying to search through a textbox to see if any of the strings in my listbox were found. So far I have no compatible code so I seek help from the professionals.
View 5 RepliesTo create a string of space characters to a given length using the MS VB namespace I used,
Strings.Space(Length)But without the VB namesapce, how do I do the same thing, is it like this?...
String.Empty.PadLeft(Length, " "c)