|
Dear all,
I am leaner to VB.At present i am trying to get data serially from arduino and plot grapgh time Vs current.I can data serially and print it on text . Now my next process is plotting single line grapgh.
[^]
example show in above link.
I am facing probelm in setting chart permaeter and label them. How to load live data in to chart w.r.t time.
Current working code
Current working code
Imports System
Imports System.IO.Ports
Imports System.ComponentModel
Imports System.Threading
Imports System.Drawing
Public Class Form1
Dim myPort As Array
Dim Distance As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myPort = IO.Ports.SerialPort.GetPortNames()
PortComboBox.Items.AddRange(myPort)
BaudComboBox.Items.Add(9600)
BaudComboBox.Items.Add(19200)
BaudComboBox.Items.Add(38400)
BaudComboBox.Items.Add(57600)
BaudComboBox.Items.Add(115200)
ConnectButton.Enabled = True
DisconnectButton.Enabled = False
End Sub
Private Sub ConnectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectButton.Click
SerialPort1.PortName = PortComboBox.Text
SerialPort1.BaudRate = BaudComboBox.Text
SerialPort1.Open()
Timer1.Start()
ConnectButton.Enabled = False
DisconnectButton.Enabled = True
End Sub
Private Sub DisconnectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisconnectButton.Click
SerialPort1.Close()
DisconnectButton.Enabled = False
ConnectButton.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
SerialPort1.Write("c")
System.Threading.Thread.Sleep(250)
Dim k As Double
Dim distance As String = SerialPort1.ReadLine()
k = CDbl(distance)
ListBoxSensor.Text = k
Catch ex As Exception
End Try
End Sub
Private Sub Relay_ON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Relay_ON.Click
SerialPort1.Write("1")
End Sub
Private Sub Relay_Off_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Relay_Off.Click
SerialPort1.Write("0")
End Sub
End Class
|
|
|
|
|
Quote: I have a project that requires more than 1 Barcode reader in the same pc How to know where the shot had come from the barcode reader., please help me sample coding in vb.net
|
|
|
|
|
This will only be possible if you have an SDK for the sepicific type of barcode reader, and the barcode reader works via that SDK only (i.e. does not emulate a keyboard). You have to read the documentation for the barcode reader.
|
|
|
|
|
|
Some barcode readers are very basic, all they do is fill in whatever control has focus. Meaning, whatever textbox has focus when you scan the barcode it will just dump the string right into the textbox. No logic or complexity to it. So, it will all depend on the barcode reader you have.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Please I'm using vb.net 2013 and I have a textbox named txtRecipients
Now i want to check for the following:
1. The phone no. should always start with 233 followed by any digit other than zero like: 233201245685
2. Multiple phone numbers should be separated by a comma, like 233201245685, and the comma replaced automatically before the start of another phone number in the same format. So if two phone numbers are entered they should be like this:
233201245685,233547345696
I did something like this in the leave event. Is there any better way to do this as the comma is not getting replaced at a specific position. I used both the remove and replaced functions, but that did not work. Thanks in advance
<pre lang="vb">
Dim str1 As String = Mid(Me.txtRecipients.Text, 1, 1)
Dim str2 As String = Mid(Me.txtRecipients.Text, 2, 1)
Dim str3 As String = Mid(Me.txtRecipients.Text, 3, 1)
Dim str4 As String = Mid(Me.txtRecipients.Text, 4, 1)
Dim str13 As String = Mid(Me.txtRecipients.Text, 13, 1)
If str1.Trim <> 2 Then
Me.txtRecipients.Focus()
MsgBox(The first digit must be 2)
Exit Sub
End If
If str2.Trim <> 3 Then
Me.txtRecipients.Focus()
MsgBox(The second digit must be 3)
Exit Sub
End If
If str3.Trim <> 3 Then
Me.txtRecipients.Focus()
MsgBox(The third digit must be 3)
Exit Sub
End If
If str4 = 0 Then
Me.txtRecipients.Text.Replace(0, String.Empty)
Me.txtRecipients.Focus()
MsgBox(Phone No. must not start with 0. Format e.g. 233243404804)
Exit Sub
End If
If str13 <> "," Then
' Me.txtRecipients.Text.Replace(str13, ",")
Me.txtRecipients.Focus()
MsgBox(Phone No. must not start with 0. Format e.g. 233243404804)
Exit Sub
End If
</pre>
-- modified 23-Sep-14 13:46pm.
|
|
|
|
|
I will use first a split on the comma(Me.txtRecipients.Text.split(",") and walk throu the array. Check the first tree chars in 1 time. string.substring()
check the others with like (string like "233#####")
Jan
|
|
|
|
|
I have this
textbox that users enter their names, but
I realized that they enter their names by entering so many spaces. I used the
replace function but it does not work well. Is there anyway to prevent this at
keypress, when the user tries to press the space bar more than once? Thank you,
all.
|
|
|
|
|
Member 11078565 wrote: I used the replace function but it does not work well. What does that mean? Did you use it correctly?
yourString = yourString.Replace(" ", " ")
or with Regular Expressions:
yourString = System.Text.RegularExpressions.Regex.Replace(yourString,"\\s+"," ")
|
|
|
|
|
Trap the keydown/up event, inspect the current and previous characters in the string, if they are both a space then deal with it in the event.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am making a little app and I am stuck. I have a multilined textbox and I would like a button to take the text and reverse the line order. So if the text was numbered each line as 1->9, pressing the button will reorder the lines so they are 9->1.
|
|
|
|
|
Member 11096018 wrote: I am making a little app and I am stuck. Where are you stuck? Edit your message and show exactly which part you are having problems with.
|
|
|
|
|
i figured it out
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim counter As Integer = txtNames.Lines.Length - 1
' create array to reverse line order
ReDim fileNames(counter)
For iLine = 0 To counter
fileNames(counter) = txtNames.Lines(iLine)
Next iLine
' using the array building a string starting from the end of the array
Dim list As String = ""
For iLine = 0 To counter
list = list + txtNames.Lines(counter) + vbCrLf
counter = counter - 1
Next iLine
'display results
txtNames.Text = list.Trim
End Sub
modified 20-Sep-14 4:26am.
|
|
|
|
|
Good day friends! Please, does anyone know where I can download ebook for dx 11 and vb?
|
|
|
|
|
Sorry to state the obvious, but I would try Google.
|
|
|
|
|
You're not going to find any books on VB6 any more let alone with DirectX support in them.
Managed DirectX died quite a long time ago but there are third party alternative like SlimDX and SharpDX, though, there aren't any books on those libraries as far as I can find.
|
|
|
|
|
PictureBox1.Left += And() +6
if PictureBox1.left > 1000 then
PictureBox1.location = new point (150, 140)
end if
thanks
|
|
|
|
|
That first line is not valid VB.NET code. It'll never compile so there's really nothing to convert it to.
Seriously, VB6?? It's been dead for quite a long time now.
|
|
|
|
|
Seems that line
PictureBox1.Left += And() +6
is erratic - or do you really have a function named 'And'?? If so you'll have to enclose this VB key word in square brackets like
PictureBox1.Left += [And]() +6
otherwise remove it to:
PictureBox1.Left += 6
This will move your picture box 6 pixel to the right an if resulting position exceeds 1000 pixel, the picturebox position will be reset to a default.
|
|
|
|
|
Hello !
I'm using VB.net 2013 and SQL server 2008R2.
I'm writing a financial application , and I'm not sure about which data type to use.
I know that decimal is more precise that float , but I read that using decimal can significantly decrease the speed of calculations and the speed of storing data to database , so the speed of the application.
Is this true , and if yes is there a solution or should I continue to use float ?
Thank you !
|
|
|
|
|
dilkonika wrote: writing a financial application Are you sure that you need decimal/float here? What about storing/calculating with Cents instead of Dollars - thus avoiding fractions at all?
|
|
|
|
|
For finacial calculations SQL Server has a MONEY datatype
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Never use float (or double) for financial applications, as they are base 2 numbers and cannot accurately hold base 10 values. You can sometimes use integers, depending on the currency and values you need to represent.
|
|
|
|
|
I have to use a kind of data type that accept digits after decimal point.
so I need to choose between float and decimal.
But it is true that working with decimal is about 20 times slower than working with float ?
This is my question.
Thank you !
|
|
|
|
|
dilkonika wrote: have to use a kind of data type that accept digits after decimal point.
Not if you get a little creative. Multiple all values by 100 and You can use integer types quite easily.
If you're still thinking about using single/double/float for money values, think again. Try this and see what you get:
static void Main(string[] args)
{
float x = 12345678.33f;
Console.WriteLine(string.Format("{0:N8}", x));
}
|
|
|
|