|
Psst to thank him properly up vote the answer - arrows appear top left of the answer box.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
have clicked the green arrow
|
|
|
|
|
how to create a VB ActiveX interface. any link to this appreciated
Thanks,
|
|
|
|
|
That is not a question that can be answered in a few words. You should head over to Google[^] and find some useful articles/tutorials.
|
|
|
|
|
In a vb.net desktop application, I want to find the substring value of '896', '558957', '5/2/2016', '3150', '1', '018.99', '', '18.99', '8277', '17', '12/4/2017', '1789655895720160502315018.99', 'Y'
that is contained with a 'sqlid' string field.
An example of the field that comes in is the following:
"INSERT INTO tblInvoiceData(SchNum,InvNum,InvDate,ItemNum, Quantity,UnitPrice,Credit,Amount,VendorId,CatId,Boarddate,RecordId,Imported )VALUES ('896', '558957', '5/2/2016', '3150', '1', '018.99', '', '18.99', '8277', '17', '12/4/2017', '1789655895720160502315018.99', 'Y')"
.
I want to display these values so the user of the application can find the record within the input file that is causing the error. This message is
displayed basically when there are duplicate records.
Thus can you show me the code in vb.net on how to accomplish my goal?
|
|
|
|
|
You need to write an SQL SELECT query to find all records containing those values. Or just get a subset and manually check for the others. And, saving date values as text strings in a database is not the best design.
|
|
|
|
|
Can you show me the query you are referring to?
The values you see come in from a text input file from the user. Thus there are no direct dates being accessed directly from the database
|
|
|
|
|
dcof wrote: Can you show me the query you are referring to? I already told you, it will need to be a SELECT statement. And I am afraid your second sentence above does not make sense. Your INSERT statement is clearly inserting date values as strings.
|
|
|
|
|
If I've understood what you're asking for, you have a string containing an INSERT command, and you want to extract the values.
The best way to do that would be with a Regular Expression:
Regular Expression Language - Quick Reference | Microsoft Docs[^]
For example:
Public Class StatementInfo
Private ReadOnly Shared Parser As New Regex(
"INSERT\s+(INTO\s+)?(?<table>[^(]+)\s*\((?<col>[^,)]+)(,\s*(?<col>[^,)]+))*\)\s*VALUES\s*\((?<val>[^,)]+)(,\s*(?<val>[^,)]+))*\)",
RegexOptions.IgnoreCase Or RegexOptions.ExplicitCapture)
Public Shared Function Parse(ByVal input As String) As StatementInfo
Dim match As Match = Parser.Match(input)
If Not match.Success Then Return Nothing
Dim tableName As String = match.Groups("table").Value
Dim columnNames As List(Of String) = match.Groups("col").Captures.Cast(Of Capture)().Select(Function (c) c.Value.Trim()).ToList()
Dim values As List(Of String) = match.Groups("val").Captures.Cast(Of Capture)().Select(Function (c) c.Value.Trim()).ToList()
If values.Count <> columnNames.Count Then Throw New ArgumentException("Mis-matched columns and values")
Return New StatementInfo(tableName, columnNames, values)
End Function
Private Sub New(ByVal tableName As String, ByVal columnNames As List(Of String), ByVal values As List(Of String))
Me.TableName = tableName
Me.Values = columnNames _
.Zip(values, Function (c, v) New With { .Key = c, .Value = v }) _
.ToDictionary(Function (p) p.Key, Function (p) p.Value, StringComparer.OrdinalIgnoreCase)
End Sub
Public ReadOnly Property TableName As String
Public ReadOnly Property Values As IReadOnlyDictionary(Of String, String)
End Class Usage:
Dim line As String = "INSERT INTO tblInvoiceData(SchNum,InvNum,InvDate,ItemNum, Quantity,UnitPrice,Credit,Amount,VendorId,CatId,Boarddate,RecordId,Imported )VALUES ('896', '558957', '5/2/2016', '3150', '1', '018.99', '', '18.99', '8277', '17', '12/4/2017', '1789655895720160502315018.99', 'Y')"
Dim statement As StatementInfo = StatementInfo.Parse(line)
If statement IsNot Nothing Then
Console.WriteLine("Table: {0}", statement.TableName)
For Each pair As KeyValuePair(Of String, String) In statement.Values
Console.WriteLine("{0} = {1}", pair.Key, pair.Value)
Next
End If Output:
Table: tblInvoiceData
SchNum = '896'
InvNum = '558957'
InvDate = '5/2/2016'
ItemNum = '3150'
Quantity = '1'
UnitPrice = '018.99'
Credit = ''
Amount = '18.99'
VendorId = '8277'
CatId = '17'
Boarddate = '12/4/2017'
RecordId = '1789655895720160502315018.99'
Imported = 'Y'
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks. That answers the question
|
|
|
|
|
How to call a 'C' program function from VB?
Thanks,
Nice things do nice works
|
|
|
|
|
You already posted this in the C forum; please do not crosspost.
|
|
|
|
|
I have written a .VBA program with the help of few forums, this help me to notify if I send email to different domain.
I have three accounts in my mailbox, when I run the above .VBA program, it applies on all three accounts. What I need is, I need this program to be executed when I send email only from two accounts.
For example, I have three accounts "@acc-1", "@acc-2" & "@acc-3", I need to get notified only when I send email from "@acc-2" & "@acc-3". So that I can send email from "@acc-1" to other domains.
Here is my code, please help me with this concern.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim recips As Outlook.Recipients
Dim recip As Outlook.Recipient
Dim pa As Outlook.PropertyAccessor
Dim prompt As String
Dim strMsg As String
Const PR_SMTP_ADDRESS As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
Set recips = Item.Recipients
For Each recip In recips
Set pa = recip.PropertyAccessor
If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@ex1.com") = 0 Then
If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@ex2.com") = 0 Then
If InStr(LCase(pa.GetProperty(PR_SMTP_ADDRESS)), "@ex3.com") = 0 Then
strMsg = strMsg & " " & pa.GetProperty(PR_SMTP_ADDRESS) & vbNewLine
End If
End If
End If
Next
If strMsg <> "" Then
prompt = "This email will be sent outside of your company to:" & vbNewLine & strMsg & "Do you want to proceed?"
If MsgBox(prompt, vbYesNo + vbExclamation + vbMsgBoxSetForeground, "Check Address") = vbNo Then
Cancel = True
End If
End If
End Sub
|
|
|
|
|
The VBA code doesn't run for a specific account. There's no way to make that happen. Instead, what you have to do is check the FROM address on the email and determine if it's from the account you want.
|
|
|
|
|
Hello,
I've searched around and cannot find an answer for this; maybe it can't be done.
I need to pass a conditional directive (TEST = 1) to a sub-project.
I've defined the directive in the Advanced Compile Options as shown 'TEST = 1'
without single quotes and it works in the primary project but the sub-project does not detect it.
In sub-project I test just like the primary project:
#if TEST = 1 then
' do something
#end if
If this can be done, could someone tell me how?
Thank you
|
|
|
|
|
Each projects stands on it's own. Compiler directives don't "trickle down" from one project to another.
You have to define the directive in each project where you want it to apply.
|
|
|
|
|
Thanks for the info
|
|
|
|
|
Add reference to Microsoft visual C Versions 7.0.5000
error was due to CustomVertex.TransformedColored.Format
|
|
|
|
|
It's not "our" example.
Articles are supported by the people who wrote them, all volunteers.
Post your question at the bottom of the article you're referring to.
|
|
|
|
|
Hello friends
I have a MONTANA 680 GPS device and I want to extract NMEA sentences from the device by VB.Net. My GPS radio has the option "NMEA IN/OUT" among other settings. My ASUS laptop has no COM port. It has only usb ports. I use SERIALPORT object to read the NMEA sentences. But the code gives the error COM port,say, com3, does not exist. Do I need to make some special setting on my GPS radio? How do I code to access and get NMEA sentences? I use Visual Basic programming language.
Thank you very much for your help.
modified 24-Jun-18 10:14am.
|
|
|
|
|
Check which COM port the device actually shows up on when you connect it.
|
|
|
|
|
Hi Friend,
Thank you for your response. When I connect Montana 680 to the USB port, it is shown as a mass storage device in Device Manager (Serial Bus). I need to get NMEA sentences from the gps device. However I do not know how to do it. My VB.net code works well with the Etrex Vista gps device that uses COM port.
But I really do not know how to resolve the problem with MONTANA 680.
Thank you for any help of you.
|
|
|
|
|
|
Hi friend
My gps device is connected to my ASUS laptop through usb (cable) and has no COM ends.
|
|
|
|
|
You need to do what I suggested before and study the documentation for the device.
|
|
|
|
|