Please .. i really need help to solving this problem ..
With my mobile .. manually i type this code ( *99# ) to display my number phone .. and this message will appear without any problem (MSISDN: 21677245978) ..
I wanted to get my number phone with this code :
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.SerialPort1.PortName = "COM5"
Me.SerialPort1.BaudRate = "1200"
If Not (Me.SerialPort1.IsOpen = True) Then
Me.SerialPort1.Open()
End If
Me.SerialPort1.Write("AT+CUSD=1," & Convert.ToString(Chr(34)) & "*99#" & Convert.ToString(Chr(34)) & ",15" & System.Environment.NewLine)
System.Threading.Thread.Sleep(7000)
Me.RichTextBox1.Text = System.Text.RegularExpressions.Regex.Match(Me.SerialPort1.ReadExisting, "(?<=\:).+").Value.Trim
End Sub
But unfortunately the last two digits number phone does not appear and i get this result in my RichTextBox1 (MSISDN: 216772459, 15)
I'm not sure but probably increase the "34" from Convert.ToString(Chr(34)).
By the way I am not that experienced but try trial and error on anything that you think the code can be changed just try it.
Related
I am trying to retrieve a surfer from a list on a textfile, the user selects the surfer from the combo box which then displays that surfers data in a bunch of labels. My code requires each surfer to have an ID for it to be able to know which record to retrieve from the database. However when I try to put my ID from my loop together with each surfers name, I receive an error saying "Conversion from string to type 'Long' is not valid." I have tried different methods of getting around this, none of which have worked. Here is my code:
Private Sub Lookup_Load(sender As Object, e As EventArgs) Handles MyBase.Load
madelabel = False
For i = 1 To maxrecJudge
FileGet(2, ajudge, i)
recnoJudge = i
judgename = recnoJudge And " " And ajudge.name
cmbJudge.Items.Add(judgename)
Next i
For i = 1 To maxrecSurfer
FileGet(1, asurfer, i)
recnoSurfer = i
surfername = recnoSurfer And " " And asurfer.name
cmbSurfer.Items.Add(surfername)
Next i
End Sub
Private Sub cmbSurfer_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbSurfer.SelectedIndexChanged
recnoSurfer = CInt(Val(New Text.StringBuilder((From ch In cmbSurfer.Text.ToCharArray Where IsNumeric(ch)).ToArray).ToString))
FileGet(1, asurfer, recnoSurfer)
If madelabel = False Then
lblName = New Label
lblName.Top = 160
lblName.Left = 253
lblName.Autosize = True
lblName.Text = asurfer.name
Me.Controls.Add(lblName)
End Sub
For simplicity I have only included one label creation above, but there are several labels spawned each with data of the surfer.
Am I on the right track with this? In the second sub my code extracts the integer (ID) from the combo box which then is used as a record number to find the rest of the data. The error relates to these lines:
surfername = recnoSurfer And " " And asurfer.name
cmbSurfer.Items.Add(surfername)
It won't let me concatenate the ID and the surfers name. Any help?
If you are doing a lot of concatenation, use a StringBuilder. It is far quicker. Every time you concatenation strings, a new string is created. Over a large amount of iterations, StringBuilder is the better choice.
I populate DataGridView with data and depending on the data I put an image in the 12th column either succes or fail. My goal is to be able to double-click on the 12th cell and show MsgBox with the status inside. I can pretty much do all whats was asked in the homework. However I can't tell in IF CONDITION; if the image in the 12th row = to succes;
here's the error;System.InvalidCastException : 'L'oerator '=' not defined for type 'Bitmap' and type 'Bitmap'.'
thank you for all the help
Private Sub DgvTest_CellMouseDoubleClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvTest.CellMouseDoubleClick
If e.ColumnIndex = 12 And dgvTest.Rows(e.RowIndex).Cells("status").Value = imgList.Images.Item("fail") Then
Dim numTest As String = dgvTest.Rows(e.RowIndex).Cells.Item(0).Value
For Each i As Test_Auto In lst_Test_Auto
If i.No_Test = numTest Then
If i.status = False Then
MsgBox("status of test #" & numTest & " ; " & "a generated and error: " & i.message)
End If
End If
Next
End If
End Sub
I have to prepare a school project of a Currency Converter in Visual Studio using Basic language.
I get the value of extange from XE website and it returns a string like "1.23454 GBP' So I need to remove most characters and numbers from it to have it as a Decimal, not String anymore so I can times it later in calculation.
I've tried to use .Remove anywhere and place it in textBox or Label but it didn't work.
Public Class receipt
Private Sub receipt_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim testString As String = "sadasdasd"
customername.Text = "Name: " + My.Settings.Username
Label6.Text = "Entered Money: " + My.Settings.inputamount + " " + My.Settings.currency
Label7.Text = "Converted To: " + My.Settings.outputamount
Label8.Text = "Charge: 0 (0%)"
TextBox1.Text = testString.Remove(4, 9)
End Sub
End Class
Screenshot of program running
Can someone help me to get this work?
Given your current input of "sadasdasd" and your expected return value then the call to string.Remove should be
TextBox1.Text = testString.Remove(3)
If you look at the MSDN documentation page of string.Remove you could see that the index is zero based so you want to remove anything starting from the fourth character that is at index 3 (keeps 0,1,2, removes from 3)
Also It seems that you think that the Remove second parameter is the end index where the Remove action should stop. But this is wrong, the second parameter is the number of characters to remove so 9 is not correct and probably gives you an ArgumentOutofRange Exception
datagridview table
please can you help i have this problem i tried a lot of code but nothing work
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)Handles Button4.Click
For RowsCount = 0 To DataGridView1.Rows.Count - 2
For Each dgvr As DataGridViewRow In DataGridView1.Rows
If dgvr.Cells(0).Value.ToString = " " Then
dgvr.Cells(0).Value = ""
End If
Next
Next
End Sub
what want to do is to remove the space between all number in the column Tel
and remove the zero and left i want all number to be like this without space or 0 like this 48802967 so please can anyone help i'm new in coding
the DataGridView is loaded from a mysql database
I think you want to remove all spaces in the telephone number column.
Use String.Replace (it's the fifth column, isn't it? Then use Cells(4)):
Dim value = dgvr.Cells(4).Value
If value IsNot Nothing
dgvr.Cells(4).Value = value.ToString().Replace(" ", "")
End If
However, in general it's the best approach to do it in the first place, the database. So either remove them before you store them or at least always when you select them.
SELECT REPLACE(tel, ' ', '') AS Tel FROM TableName
If you also want to remove leading zeros of the phone number:
dgvr.Cells(4).Value = value.ToString().TrimStart("0"c).Replace(" ", "")
I have a groupbox with 5 NUD controls. I am trying to figure out if there is a way to limit the TOTAL value of all of the NUD combined, and to set a restriction to where it has a minimal amount required of them all combined. I checked my book for school and cannot seem to find it in there nor is google providing me with the answer I seek. This is not a requirement of my project, I just thought the extra touch to it would be nice. Any help would be appreciated. Thanks.
EDIT:
I tried using an array but wasn't getting the results I was looking for, still searching around to find a way for people to not able to increase the value of said NUD's when limit is reached. This is what I currently am doing and just don't like the way its handled, I would prefer them not to press a button to find out if the total is more than the requirement.
If numForest.Value + numFountain.Value + numConstruct.Value + numIntercept.Value + numWaterFall.Value > 30 Then
MessageBox.Show("Total photo prints needs to be below 30")
Else : lstPhotoOrder.Items.Add(txtOrderName.Text)
As Plutonix hinted, you can use the ValueChanged event to examine the current value of the NumericUpDown controls. The problem is, it doesn't tell you what the previous value was to fall back to, so try storing those values in a dictionary:
Private oldNums As New Dictionary(Of NumericUpDown, Decimal)
Private revertingValue As Boolean = False
Private Sub num_ValueChanged(sender As Object, e As EventArgs) Handles _
numForest.ValueChanged, _
numFountain.ValueChanged, _
numConstruct.ValueChanged, _
numIntercept.ValueChanged, _
numWaterFall.ValueChanged
If Not revertingValue Then
Dim numControl As NumericUpDown = sender
If Not oldNums.ContainsKey(numControl) Then
oldNums.Add(numControl, numControl.Minimum)
End If
If numForest.Value + numFountain.Value + numConstruct.Value + _
numIntercept.Value + numWaterFall.Value > 30 Then
MessageBox.Show("Total photo prints needs to be below 30")
revertingValue = True
Try
numControl.Value = oldNums(numControl)
Catch ex As Exception
Finally
revertingValue = False
End Try
numControl.Select()
Else
oldNums(numControl) = numControl.Value
End If
End If
End Sub