viernes, 11 de octubre de 2013

Search characters into a string in Visual Basic



Since time ago I wanted to Post this entry because sometimes we want to read substrings in a main string. Of course obviously such tool doesn’t exist therefore we must create it.
Microsoft provides one tool and it is the following:

Dim text As String = "I have been playing tennis since I was a child"
Dim character As String = "I was a child"
Dim number As Integer

number = InStr(1,text, character, CompareMethod.Binary)

In this case when we want to know which is the position than one substring these code back to us the position where these. This code is amazing because you can search a string and not character, in this case when I want to search “I was a child” into “I have been playing tennis since I was a child”, this back to us the position where begin “I was a child” than is 34.

I want to show one example:

We suppose that I want to modify “I was a child” and then put “I was 19” in the main string, like this:
“I have been playing since I was 19”


Well it’s easy to resolve because we know the method and this is the following:

Dim text As String = "I have been playing tennis since I was a child"
Dim character As String = "I was a child"
Dim number As Integer

number = InStr(1,text, character, CompareMethod.Binary)

text = text.remove(number-1,13)'Add -1 because visual basic remove the text one position before the text which we want to remove.

replace(text, " ", "")'remove all spaces

text = text & "I was 19"

'We will see: “I have been playing since I was 19"

miércoles, 2 de octubre de 2013

How to make a graph with datas already save in binary files? (Use timestamp already save too)

In my last entry I was explain how to save information in binary files and how to save timestamp in binary files too In order to save up space in disk. Well in this entry I going to explain how use these information In order to graph it.

I have been making “graph XY” since I was start in Labview, but already exist many others methods that you can use, in this example I prefer this method because is more easy and fast.
For this example (If you decide follow my instructions) you need 2 files (Information file like a random numbers that it must be save as array number (don’t use array dbl) –you can use random number that includes in Labview- and timestamp files already save). These files must be save at the same time because this example explains how to graph information already captured in x time. Remember if you use the tool random number that includes in labview, you must be converts these dbl numbers to integer numbers.



When you take these files then you repeat this example again and again J


1)  The first step is build your decoders (timestamp decoder and array date number decoder) like these:





 The second step is build a bundle and then make a graph (You must select the graph in the user interface in labview)





After that you must configure this graph as follows: