Manipulate Looping Serialport.readexisting And Instr?
Jun 27, 2011i try readexisting and instr function as follow:
[code]...
i try readexisting and instr function as follow:
[code]...
I'm using the following to read a serial port. When run it displays the data correctly but stepping through the program I find that it loops through the serialdatarecieved event for each character of the port input rather than reading all of it. So _msg only equals one letter at a time. I'm trying to set a variable equal to the entire input stream but only get one character of it.The end goal is to capture all of the data available on the port when the event triggers so that this data can then be processed. I tried using the bytestoread function, which gets the correct number of bytes to read, and then looped through to read a byte at a time but that didn't seem to work as I expected either. It just kept reading the first byte.
Imports System.IO.Ports
Public Class CommTest
Dim WithEvents SerialPort As New SerialPort
[code]....
I'm trying to make a simple Class that reads data from a SerialPort.The Device returns a number of lines of Strings.
Code:Public Class Device
Private Device As New IO.Ports.SerialPort("COM4", 4800) Private WithEvents tmr As New Timer Public Event GotData(ByVal Data As String)
[code].....
i'm using the AppendText(serialPort.ReadExisting) method of the SerialPort class. i'm sending to the serial port a 12 byte frame. however in the TextBox control streams printed seem choppy as if the ReadExisting method is exiting too quick to grab all 12 bytes so i can display them at once.
View 3 RepliesRecently we have connected one bluetooth device which receive data from our serial device. The bluetooth device further transmite this data to a Windows Mobile which is bluetooth enable. Baud rate of whole system is 19200 with 7 data bit and 1 stop bit.When we send command to serial device through bluetooth device it is accepting the command and respond accordingly. but some of data byte of string is desplay as question mark (?).But in case we connect the serial device directly to PC, the string received is correct.[code]Response given by Serial Port is "?09?D03?A D?
View 1 RepliesRecently we have connected one bluetooth device which receive data from our serial device. The bluetooth device further transmite this data to a Windows Mobile which is bluetooth enable. Baud rate of whole system is 19200 with 7 data bit and 1 stop bit.When we send command to serial device through bluetooth device it is accepting the command and respond accordingly. but some of data byte of string is desplay as question mark (?).[code]...
View 4 Repliesi have a string that looks like this "Patient Name, Doc Name, Patient ID, something else"i want to extract each one of these and put it in a variable. such that var1 will equal "Patient Name" var2 will equal "Doc name" etc.. using instr and mid. what is the best way to do it?
View 3 RepliesI have the following condition
If InStr("a,b,c", stringA) > 0 OrElse (InStr("y,z", stringB) > 0 AndAlso value = 0) Then
endif
COndition 1 is false so i check for condition 2 that is "(InStr("y,z", stringB) > 0 AndAlso value = 0) "
What puzzles me is that when stringB is nothing it still falls into the if condition and executes the code.
On first look it would seem that when stringB is nothing condition2 would fail and as a result would not fall into the if condition.
for determining whether a string of data contains certain text, which is more efficient? I have read elsewhere that there is somewhat of a consensus to avoid legacy functions, since they may or may not be available in future versions.However, trying to use the contains method (or indexof equivalent of Instr) is causing me problems, I think, because I am having trouble performing a case-insensitive search.
I am trying to be efficient and functional in my code. I am reading an INI file, and I have preloaded the contents of the file into a String variable, for 2 reasons. 1) If I can test if a certain section exists in the code, I can avoid attempting to read a section of empty data (the INI reader class I have chosen returns the value or an empty string for a given request). More importantly, 2) I have created a data field that is not INI compliant (at least not to the API?) as it is a data field that can contain an arbitrary (unlimited?) amount of data which is a hex-encoded representation of serialized byte data. I need to be able to determine if this value exists in the file and retrieve it using normal string manipulation, since the INI handler will not pass strings longer than 256Chr.
So, the problem I am having is getting "strFileContents.Contains("data=")" to return true in the case where the file contains "Data=". This could be data=, DATA=, DaTa=, etc.Instr has the option "CompareMethod.Text" which, I believe, does a case insensitive text search. What is the equivalent for "Contains"?
I am developing a twitter application. I can add, delete a user but now need to load the users follower page and then add the followers. the problem is the element id's are all different. I have tried the following,, loading the html into a text box and trying to read it using instr. but could not get the instr to parse the element id which looks something like this
[Code]....
I'm looking to do is scrub an html file for anything that resembles an IP address or any set of numbers for that matter. Normally what I would do is just using things like string.split to split out the html around areas that I want to search. What I am looking to do is be able to essentially search a large amount of characters for anything that matches this reg ex pattern.
Dim pattern As String = "^(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]):(d{1,4}|[0-5]dddd|[0-5]dddd|6[0-4]ddd|65[0-4]dd|655[0-2]d|6553[0-5])$"
'InStr' is a namespace and cannot be used as an expression.Dim FirstString As String = "me@me.com"
Dim SecondString As String = "@"Dim position As Integer position = InStr(FirstString, SecondString)
If position = 0 Then MsgBox("Not a Valid email address: There was No @ Sign") End If
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 RepliesI come from a C# background but am now working mostly with VB.Net. It seems to me that the above functions (and others - eg. UCase, LCase) etc. are carryovers from VB6 and before. Is the use of these functions frowned upon in VB.Net, or does it purely come down to personal preference?
View 4 RepliesWhat i am trying to do is take a character (which is going to be into a variable by user input) and search a string for this character, and save the positions of all character found and then change the same position of these characters in another string for the character that the user inputs. In other words, like a guess a word game. User tryes a guess, i search the string for that letter or number, if it's there replace it on the text box of the GUi, if not save it in another variable as a character that has been tried already, possibly an array.
View 1 RepliesI am creating a movie player which lists movie files from various folders/subfolders in a combobox (tsFileList). I'd like to be able to enter the movie name into a textbox (txtSearch), find that text in the combobox (using instr), then automatically select the found item.I'd like to use instr as some of the items in the combobox contains full file paths.
View 3 RepliesI created a code that allows me to search inside a RichTextBox...Then the code is as follows:[code]Now with the code that I use today, the MsgBox show me only the first, ie "<b> text1 </ b>" while others are not..
View 15 RepliesI want to assign the value of the integer returned from the InStr method to a variable. So, If TextBox2.Text = "The Apple Pie" And TextBox1.Text = "App", I want the integer returned, which in this case would be 5, put into a variable, lets say its called 'VarString'.
So VarString (would) = 5.
[Code]...
I'm using this for a single value to search for.
intPositionOfApartment = InStr(StrConv(pStringToParse, vbUpperCase), "APT") Is it possible to search for more then one value such as "APT", "UNIT" ?
If yes please show me an example of how it should be coded.
I have an application in VB.NET which gets string data from the database. This string has data which looks as below:
"This is the update: I have an issue with the application"
I need only part of the data, that comes after the new line i.e. "I have an issue with the application".
For this I am trying to search the position using InStr where the string has data in a new line. I tried many options, but they don't work.
I used "vbCrLf", Chr(13), "
", "
", "<br/>", Environment.NewLine, but none of them work.
How can I get the data I need?
I'm brand new to visual basic and I've been given an exercise to extract data from a text file. I can get the lines of data to read in and can get the names out using the following code. How can I extract the department i.e. sales and finance also using the mid and instr functions? I also need to be able to list list the people by department using a dropdown combo box.
[Code]...
i have problem in manipulating DataSet, how can i filter rows without getting the whole records in tables.
[Code]...
Private sub updatelabels()
If me.invokerequired then 'entire form -- ok ?
me.invoke (new methodinvoker (addressof updatelabels))
[code].....
I have a form with a bunch of tabs on it, but I don't want them to all be visible all the time.[code]...
View 4 RepliesI am developing an intranet app (so security isn't such a problem). The client wants to drag eml files from Outlook to a folder. I would like put a file watcher control that monitors the folder. When the new file is added I want to run some javascript in the open intranet window. How can the file watcher app communicate with the intranet app (also there may be more than one intranet app open). I am experienced at asp.net but a total novice to Winforms so bear with me.
View 4 RepliesI don't know much about the CIL, except that there is metadata in assemblies that record the type information.Would it be possible to create some reflecting tool that is able to read a C# or VB.NET assembly and change its metadata so that all class members become public?
View 4 RepliesI need to create a code, that allows me manipulate a scanner for to do the functions of scanning and save the image.
View 1 RepliesI want to create and application (I'm a rather Jr. programmer, with just a few apps in production), but I'm not sure where to start.
The app needs to be able to join videos of the same types, for instance, divx1.avi and divx2.avi into divx_joined.avi.
I've already google...err I mean, searched bing for some how to's and what not, but I don't think I'm looking for the right terms.
Where do I start to learn to deal with video streams? Is there a book, SDK, etc?
I'm currently using system.data.oledb but I can't seem to make the update , search, & delete work fine. Are there any other ways on how to manipulate an ms access database in vb.net easier than my method? Here is my code for searching:
[Code]...
I had a treeview that had checkbox and its content is like file explorer. the checkbox is check when users want to delete that files or directory, after the selection, press the command button then all selection will be process (on this case deletion) how that to be code?
View 2 Replies