VS 2008 Checking How Many '.' There Are In A String
Dec 21, 2011i have a textbox in a calculator and i want an if function so that it checks that there cannot be 2 .'s in it:[code]
View 2 Repliesi have a textbox in a calculator and i want an if function so that it checks that there cannot be 2 .'s in it:[code]
View 2 RepliesI am currently using the following code to parse a webpage.
CODE:
Where it has:
CODE:
It would work, as with this:
CODE:
But i need it all in one line of code..
i have a list view that contains files i use a for statement to go with them to and check what format the file is then sets its image but i dunno how to get it to work i cant use the or statement it says it cant convert to boolean
vb
If Label1.Text = "doc" Or "docx" Then
oresults.ImageIndex = 14
ElseIf Label1.Text = "ppt" Or "pptx" Then
oresults.ImageIndex = 10
End If
I am trying to figure out how to check a string can contain a certain value.In the begining I had a checkbox and wanted to hide a ceratin field depending upon which checkboxes were selected.The problem with this is that the value is always = to the first value.
I got around this by writing these values into a hidden textBox and using a loop.So now I have a textbox and if the user selected the 1st and 3rd choice the textBox would = "AC" If they selected all choices it would = ABCD etc...How can I determine if the values in my textBox contains just letter 'B' ?
I tried this:
--------------------------
Dim values As String = [String].Empty
For Each item As ListItem In section2List.Items
If item.Selected Then
[code]....
but this doesn't work.
If Double.Parse(list_numbers.Item(i), possibledouble)
list_numbers is a list of strings
list_numbers.Item(i) = "0.000"
possibledouble is a double
debugger returns "input string was not in a correct format"
i thought that the double parse would convert the string into a double format of "0.0" but it gives me an error.
So I basically want to make sure that a string entered by the user is valid. Valid being over 10 characters, containing only upper case characters, and only characters A - Z and spaces. The first two were easy, but I'm having trouble with the third, though.What I originally attempted to do was create a loop which checks if the first invalid character is present with the InStr function, by using the characters ASCII value. The next ASCII value is then checked, and so on until it has checked the string for every single invalid character. If an invalid character gets picked up, 1 is added to a variable, and after the loop is finished executing, if the variable is no longer 0, invalid characters have been detected.
View 3 Replieshow find an object's type when it is a subclass of another object and I only know the string value of the object's type's name.
I created the follwing classes:
Public Class word
End Class
Public Class noun
[Code]...
Using 'TypeOf', I correctly see that pn is a properNoun, a noun and a word. The problem is, using 'GetType' to check pn against a string value, I can only see that pn is a properNoun, not that its parent classes are noun and word.
Is there a way to check pn against the string value "noun" or "word" and get back a positive result, indicating that pn is indeed a noun and a word as well as a properNoun?
I am trying to check if a string is numeric but in vain. here is my code:
If Val(fnumField.Text.Trim) > 0 Or fnumField.Text.Trim = "0" Or Val(phnField.Text.Trim) > 0 Or phnField.Text.Trim = "0" Or Val(ophnField.Text.Trim) > 0 Or _
ophnField.Text.Trim = "0" Or Val(treeField.Text.Trim) > 0 Or treeField.Text.Trim = "0" Then
[code].....
How find an object's type when it is a subclass of another object and I only know the string value of the object's type's name. I created the following classes:
HTML
Public Class word
End Class
Public Class noun
Inherits word
[Code] .....
Then, in my code I create a new properNoun and check to see if it is a properNoun, noun or word:
HTML
Private Sub checkTypes()
Dim pn As New properNoun
MsgBox("Is a properNoun: :" & TypeOf pn Is properNoun) 'TRUE
MsgBox("Is a noun: :" & TypeOf pn Is noun) 'TRUE
[Code] .....
I correctly see that pn is a properNoun, a noun and a word. The problem is, using 'GetType' to check pn against a string value, I can only see that pn is a properNoun, not that its parent classes are noun and word. Is there a way to check pn against the string value "noun" or "word" and get back a positive result, indicating that pn is indeed a noun and a word as well as a properNoun?
I am working on a program that will take in a string of length 7 containing either R,G or B for the colours. The program will then check that the string if 7 in length and if it contains any other characters than R, G or B then it will be invalid. I created this code but when I enter the right string length and characters it always gives me the error for not having the right string length.
Private Sub get_cars()
Dim Letter As String
Dim valid As Boolean
Dim position As Integer
txtPosition.Text = position
[Code] ......
I'm trying to figure out how find an object's type when it is a subclass of another object and I only know the string value of the object's type's name.I created the follwing classes:
HTML
Public Class word
End Class
Public Class noun[code]....
The problem is, using 'GetType' to check pn against a string value, I can only see that pn is a properNoun, not that its parent classes are noun and word.Is there a way to check pn against the string value "noun" or "word" and get back a positive result, indicating that pn is indeed a noun and a word as well as a properNoun?
Not so long ago, I saw somewhere a solution how to check if string is date in yyyyMMdd format (i.e. if it can be converted to date if written in such format). I can't find it anymore but I think is had something to do with DateTime.TryParse method but I can't get it to work. I can get it to work if string is in dd/MM/yyyy format, but dont' know how to make it with yyyyMMdd format. If I'm not mistaken neither of DateTime.TryParse method parameters is for assigning date format...
View 5 RepliesI want my program to check the pagerank of all string list items, and than add it do a listbox. Now this is my code to open a list and add it to a string list ( itemlist as list(of string)
Dim stream_reader As New IO.StreamReader(OpenFileDialog1.FileName)
Dim line As String
line = stream_reader.ReadLine()
Do While Not (line Is Nothing)
line = line.Trim()
[Code] .....
I'm using the DLL from this website: [URL]. The problem is that it only checks the first website and the other websites will be 0/10 automatically while they might be 3/10 or something else.
Is there any better performance by checking for a true value like this:
[CODE]..............
Than like this:
[CODE]..............
I'm trying to determine the framework version that is installed via the registry. When poking around, I found this key: HKLMSOFTWAREMicrosoft.NETFrameworkPolicyv4.0 I've created the following function to determine if the key exists:
[Code]...
I've verified the key exists, but it keeps returning False.
i know My.Computer.Network.Ping but as alot of people know, it's glitchy and bugged.
I want something that checks to see if it can connect with something, as simple as it sounds.
I'm experimenting with sockets at the moment, but having trouble so i thought i would come and ask here
What i'm up to:
VB
IP = Net.IPAddress.Parse(getinfo("settings.inf", i & "IP"))
socket = New Net.Sockets.Socket(Net.Sockets.AddressFamily.InterNetwork, Net.Sockets.SocketType.Stream, Net.Sockets.ProtocolType.IP)
[Code].....
However the problem with this it that i pinged 1.1.1.1 and it still connects, ALSO i would like to be able to check a hostname not just an IP to make things more convenient, please help me to find a way to properly check a connection with IP or hostname.
Note: The getinfo function is defined by me
I have two user controls that need to add a class atribute to the body tag of my page, however they currently over write one another if I just use Body.Attributes.Add("class","value") So I need to check if the class attribute exsists and if it already contains the value Im going to add.
If Not Body.Attributes("class").Contains("value") Then Body.Attributes.add("class", Body.Attributes("class") + " " + "value") End If
EDIT: The contain constraint doesnt return the expected value, resulting the the class not been concatinated, Example: add class "dog" then I a different instance of the same control tries to add "dog" but the contains("dog") returns false
In the following code, a Date variable is declared but not set to anything:
Dim myDate As Date
What's the proper method of checking if the Date variable is "new" and not set to anything?
For example, getting the lowest date value from an array of dates:
Dim dtMostRecent As Date
For i As Intger = 0 To myDateArray.Count - 1
If myDateArray(i) < dtMostRecent Then dtMostRecent = myDateArray(i)
Next
In the code above, I need a way to check first if dtMostRecent is unassigned, in which case just give it the first value, after which it can be compared with subsequent values. How to check if a Date variable is unassigned.
I've created the following function and thrown it inside of a timer:
[code]...
It works, but it keeps trying to open media player for each process it looks like. I need to continuously run the function so that Media Player opens when it's closed.how to make sure it opens only once when the process doesn't exist?
Can someone tell me why this code works exactley the opposite of the way I thought it should?
[code]...
I have a combobox (cbKeyWords). I want to make sure tbAddEdit.Text does not already exist before I save. To me I should be testing for a False result not True. But the above code, goes to the msgbox if findstringexact=false and saves the data if it's true.
I was curious why this bit of code won�t detect that the ARGB value is Blue:
[Code]...
When I run the code it says that the color isn�t Blue.
I have agroupbox control and on this groupbox control there is upto 10 checkboxes, if any of them are unchecked i was going to throw a warning "No checkboxes selected" i'm not sure how to go about it so far i have:
For Each ctrl As Control In GroupBox10.Controls
'Not sure what to do here...
Next
[code].....
I have 22 text boxes that have to be checked to see if the value has changed. I am using the TextChanged Event handler to do this thus:
Private Sub TextStringChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
DataChanged = True
RemoveHandler ........
[code]....
The Handler would be added after the data had been loaded. The question is:Is there another way of checking for text changes without having to add and remove 22 handlers.
I'm having trouble using the HasChanges method.I'm trying to get a message box to show if a user hits the edit button, makes a change, then hits the close button without hitting the save button first. From what I understand, the HasChanges(DataRowState.Modified) statement should work.In reality, when I hit the edit button, make a change to a field (zip for example), then hit the close, it just closes without showing the messagebox.Here's my code so far...
Private Sub CustomerForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) _
Handles Me.FormClosing
[code].....
I am trying to have my program check for the existence of a registry key so I do not get a null reference exception error. The key may or may not exist depending on the computer. How can I check to see if it exists and then change its value if it does exist or skip over it to the next one if it does not exist? (I already know how to change the value part of it) Im just not sure how to check for the existence of it for example would be trying to set the value of a key that does not exist called test below... this obviously would throw a null exception error so how do I check for the existence of the key before executing these instructions and then if it does not exist it skips this and keeps going to the next code ?
Dim testkey As RegistryKey = Registry.LocalMachine.OpenSubKey("SystemCurrentControlSetTEST", True)
Dim keyval As Int32
' Set to ON
keyval = 1
testkey.SetValue("ON", keyval)
I also check the status of the registry entry on form load
Dim Test As RegistryKey = Registry.LocalMachine.OpenSubKey("SystemCurrentControlSetMYTEST", False)
'Get the reg value.
Dim Testflag As Integer = CInt(Test.GetValue("ON"))
[code]....
I have tried to solve this myself and I know I am probably doing something really silly here what I have is two different registry values that control what is displayed in the combobox on my form RegistryKey1 has the following values:0,1 or it does not existRegistryKey2 has the following values2,3, or 4 the combobox has the following values 0,1,2,3 However here is the problem if the RegistryKey2 is 2 then it further has to be checked if RegistryKey1 is either 0,1 or does not exist
if it is 1 then the selectedindex = 0
if it is 0 or does not exist then the selectedindex = 1
if RegistryKey2 is 3 then the selectedindex = 2
[code].....
Suppose I have 5 Integers(A, B, C, D, and E) and 5 Textboxes. When the program run, the user is going to input 5 numbers to those 5 textboxes. When a button is pressed, a label will show up and write the textbox number with the biggest number.
View 1 RepliesI'm very green with VB Express 2008 and am going through the tutorial. I'm skipping over a lot of the exercises as some of it is review for me - I've a fairly solid background in MS Access VBA and forms design there. But I have a simple question on VB Express forms design (I'm not worried about data handling or anything yet).How do I test a form? In my first form on my project, I just press F5 (Start debugging) and it opens just fine. However, I'm playing around with a second form in design mode and can't seem to get it to open to test some of the code (simple msgboxes associated with buttons).
In Access 2003 and earlier, there was a design mode and form view. The Access design mode was the equivalent of the design tab in the VB project, but I can't seem to find the equivalent of the Access form view in VB so that I can open that form. VB F5 only seems to open the first form.BTW, is VS 2008 the correct tag/prefix for this question on VB Express 2008? I see there's a separate tag list - is there an approved list of tags aside from the prefix before the title in the posting screen?
I'm checking is a file exists as follows.
If txtGradeObs.Text = "" Or Dir(txtGradeObs.Text) = "" Then
MsgBox("Specify the Grade job of Obstructions", vbExclamation, MsgBoxTitle)
Exit Sub
End If
I get an error if the drive does not exist - i.e. G: rather than C:. It used to work in VB6. How can I get it to work.
I want to make a program where I can chose a COM port (For example COM 1), then check if it's working. It would be really useful for me, seeing as I work a lot with broken COM cards.
View 1 Replies