|
There is no IPC between languages. There is between applications.
You haven't described what you're doing in VBS and in the C# code, not even what kind of app you've written in C#. Is this a COM component, a Windows Forms app, WPF app, ... ? What?
VBS cannot directly call Win32 functions, including SendMessage, but it can be done using a custom COM-component.
You're going to go into a lot more detail about what you're doing to get any meaningful answer.
|
|
|
|
|
Oh, I'm sorry to give any detail that I want to do.
Because I'm beginner here, just thought WPF is the only APP for C#, I applogize
My plan is, send data from VBS to WPF app.
I mean, Communication Between two programs in local computer not through the internet
For example,
Dim Data = "Hello"
I want to transmit "Hello" from VBS to WPF APP, and invoke popup message from WPF APP as "Hello"
If I can make two-way communication between VBS and WPF APP, it would be the best
but, To build VBS for Trasmission and WPF for Reception is also enough
Thank you
|
|
|
|
|
A better what to do that would be to use an Inter Process Communication method (IPC), like named pipes or memory mapped files.
The problem here is that VBScript doesn't have any native way to do any kind of IPC. It would take writing a COM-based component that your VBScript code can use (see the CreateObject function) to handle the IPC heavy lifting.
You would also have to implement the "server-side" of the communication channel in your WPF app.
|
|
|
|
|
Dear friends
please help me how to deal with this error object variable with block variable not found not found
|
|
|
|
|
You have to show us the code that is causing the error for us to even have half a chance of helping you!
|
|
|
|
|
You haven't supplied the code you're having a problem with and you expect someone to be able to help you?
|
|
|
|
|
unable to create a win-from for mailing 2 many clients using vb.net
|
|
|
|
|
You have our sympathies.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Dear Friends at code project,
The code i use is as follows
Private Sub BtnExcel_Click(sender As Object, e As EventArgs) Handles btnExcel.Click
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim dataSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim path As String = "C:\Users\Abhimanyu Singh\Documents\excel\SalarySlip.xlsx"
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [salaryslip$]", MyConnection)
dataSet = New System.Data.DataSet
MyCommand.Fill(dataSet)
DataGridView1.DataSource = dataSet.Tables(0)
MyConnection.Close()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
End Class
It works well for a single Excel file but if i try to open another fileit gives me error
"OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET"
IAM NOT ABLE TO MOVE AHEAD PLEASE SUGEST REMIDIES
|
|
|
|
|
Again. Without the code you're using and a description of any problem or errors you're having, it's impossible for anyone to help you.
Stop typing as little as possible.
|
|
|
|
|
I'm using ToolStripProfessionalRenderer to customize a toolstrip. The toolstrip buttons are generated programmatically as needed. The program starts with three buttons. I'm using a LinearGradientBrush to paint the ToolStripButtons, but only the first one (left) gets the gradient. Using the renderer is new to me, so I'm probably missing something obvious.
Private Sub menuRndr_RenderButtonBackground _
(sender As Object, e As ToolStripItemRenderEventArgs) _
Handles Me.RenderButtonBackground
Try
If e.ToolStrip.Equals(main.tabs) Then
Dim p As New Pen(Brushes.Black, 1)
Dim lgb As New LinearGradientBrush(e.Item.Bounds,
Color.SteelBlue,
Color.WhiteSmoke,
LinearGradientMode.Vertical)
e.Graphics.FillRectangle(lgb, e.Item.Bounds)
e.Graphics.DrawRectangle(p,
New Rectangle(New Point(e.Item.Bounds.Left, e.Item.Bounds.Top),
New Size(e.Item.Bounds.Width, e.Item.Bounds.Height)))
End If
MyBase.OnRenderItemBackground(e)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
Hi Gerry this is Doss. Thanks for your advice.
Then I try something altered my code with your advice. Finally I get the result. MDI Child form is do transparent. First i put the code in the parent form and put the code in a child form. It is worked OK.
At the same time i want see the contents of controls another child form behind the transparent child form but the transparent child form didn't show the contents of other child forms. what can i do. please help.
And how can i upload a sample images of my project result?(sorry my poor language)
|
|
|
|
|
You have to post such of content to an author of article (under the article). Use "Have a question or comment" widget.
|
|
|
|
|
This is supposed to be a reply to a solution in QA[^]. You have already posted it as a comment there. DO NOT post it in the forums. It makes absolutely no sense here.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This keep generating an error...
Dim number As Integer
number = Convert.ToInt32(Console.ReadLine())
|
|
|
|
|
That's because whatever you're typing on the command line isn't convertible to an integer. An empty string is NOT convertible.
Forget using Convert and use Integer.TryParse instead.
|
|
|
|
|
Console.ReadLine Method (System) | Microsoft Docs returns string. So, you have to define string variable, read line from console and then convert string into integer. Please, use Int32.TryParse Method (System) | Microsoft Docs:
Dim ci As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("PL-pl")
Dim format As System.Globalization.NumberStyles = System.Globalization.NumberStyles.AllowLeadingSign
Dim line As String = Console.ReadLine()
Dim number As Integer = 0
If Int32.TryParse(line, format, ci, number) Then
Console.WriteLine($"You have entered {number}")
Else
Console.WriteLine($"Can't convert '{line}' into number!")
End If
Good luck!
|
|
|
|
|
Hello.
I have static library and I need to add it to VB project.
How can I do it ?
I am working in VisualStudio 2013
Thanks in advance.
Andrii.
|
|
|
|
|
That depends on what you mean by "static library".
Is this supplied in a .DLL? Where did this library come from? Is this COM-based? A function library? Got any documentation on it?
|
|
|
|
|
Hello everyone ,
I am trying to retrieve XML information, I managed to recover the attributes against the childrens (<pre><ToolLine Text=" )they are not recovering below my code and the form of my XML file:
XML template :
<pre lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<Root>
<ToolsList>
<Tool PartNumber="0018B">
<ToolLine Text=" FI : 3897" />
<ToolLine Text=" PINCE1 Reference : M 22520/2.01" />
<ToolLine Text=" Position : 2.02" />
<ToolLine Text=" Reglage : 7" />
<ToolLine Text=" PINCE2 Reference: M 22520/7.01" />
</Tool>
</ToolsList>
</Root>
Code C#:
<pre lang="vb">Imports System.IO
Imports System.Xml
Module ParsingUsingXmlDocument
Sub Main()
Try
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
'Create the XML Document
m_xmld = New XmlDocument()
'Load the Xml file
m_xmld.Load("D:\Users\Desktop\Xml to excel chahine\U881A1013_105_A_PREP_1.xml")
m_nodelist = m_xmld.SelectNodes("/Root/ToolsList/PartNumber")
'Loop through the nodes
For Each m_node In m_nodelist
Dim partnumber = m_node.Attributes.GetNamedItem("PartNumber").Value
'Get the firstName Element Value
Dim text1 = m_node.ChildNodes.Item(0).InnerText
Dim text2 = m_node.ChildNodes.Item(1).InnerText
Dim text3 = m_node.ChildNodes.Item(2).InnerText
Dim text4 = m_node.ChildNodes.Item(3).InnerText
Console.Write("partnumber: " & partnumber _
& " text1: " & text1 & " text3: " _
& text3)
Console.Write(vbCrLf)
Next
Catch errorVariable As Exception
'Error trapping
Console.Write(errorVariable.ToString())
End Try
End Sub
End Module
if you have any ideas do not hesitate to help me, thanks in advance
after a question how can I implement this information on an excel file
|
|
|
|
|
Member 14506089 wrote:
m_xmld.SelectNodes("/Root/ToolsList/PartNumber") Based on the XML provided, the node under ToolsList is called Tool , not PartNumber .
Member 14506089 wrote:
m_node.ChildNodes.Item(0).InnerText InnerText returns the text between the opening and closing tags. You are trying to read the value of an attribute. You cannot read an attribute value using the InnerText property.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry for so much code but I think you need to see all of it.
The below code works for a 32 bpp image but using a 24 bpp image. The resulting
24 bpp image is skewed; it looks like by 1 pixel. The skewing starts at the top an skews
to the right down the image. I've tried messing with indices and widths but can not
get a clue as to what's happening.
Am I missing something really simple?
Public Sub CropImage()
'Source image in a PictureBox
Dim _arRGBValues() As Byte
Dim _BMPData As Imaging.BitmapData
Dim _BMPPtr As IntPtr
Dim bmSrc As Bitmap = Me.Image.Clone()
Dim rect As New Rectangle(0, 0, bmSrc.Width, bmSrc.Height)
_BMPData = bmSrc.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmSrc.PixelFormat)
_BMPPtr = _BMPData.Scan0
If bmSrc.PixelFormat = Imaging.PixelFormat.Format24bppRgb Then
' 24bpp
Dim bytes As Integer = (bmSrc.Width * bmSrc.Height) * 3
ReDim _arRGBValues(bytes - 1)
System.Runtime.InteropServices.Marshal.Copy(_BMPPtr, _arRGBValues, 0, _arRGBValues.Length)
Else
' 32bpp
Dim bytes As Integer = (bmSrc.Width * bmSrc.Height) * 4
ReDim _arRGBValues(bytes - 1)
System.Runtime.InteropServices.Marshal.Copy(_BMPPtr, _arRGBValues, 0, _arRGBValues.Length)
End If
' Destination image
Dim arCropValues() As Byte
Dim cropData As Imaging.BitmapData
Dim cropPtr As IntPtr
' Size to src bm above - 1 pixel in width to allow for 1 pixel offset; height is the same.
Dim bmCrop As Bitmap = New Bitmap(bmSrc.Width - 1, bmSrc.Height, bmSrc.PixelFormat)
Dim cropRect As New Rectangle(0, 0, bmCrop.Width, bmCrop.Height)
cropData = bmCrop.LockBits(cropRect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmCrop.PixelFormat)
cropPtr = cropData.Scan0
If bmCrop.PixelFormat = Imaging.PixelFormat.Format24bppRgb Then
' 24bpp
Dim bytes As Integer = (bmCrop.Width * bmCrop.Height) * 3
ReDim arCropValues(bytes - 1)
System.Runtime.InteropServices.Marshal.Copy(cropPtr, arCropValues, 0, arCropValues.Length)
Else
' 32bpp
Dim bytes As Integer = (bmCrop.Width * bmCrop.Height) * 4
ReDim arCropValues(bytes - 1)
System.Runtime.InteropServices.Marshal.Copy(cropPtr, arCropValues, 0, arCropValues.Length)
End If
' Copy from source image
Dim colour As Color
' Start at column 1; 1 pixel column offset
Dim xOffset As Integer = 1
Dim yDst As Integer = 0
For ySrc As Integer = 0 To Me.Image.Height - 1
' Copy starting at bmCrop column 0
Dim xDst As Integer = 0
' Starting at bmSrc column xOffset
For xSrc As Integer = xOffset To Me.Image.Width - 1
' Get pixel
If bmSrc.PixelFormat = Imaging.PixelFormat.Format24bppRgb Then
' 24bpp
Dim index As Integer = ((ySrc * bmSrc.Width) + xSrc) * 3
Dim b As Integer = _arRGBValues(index)
Dim g As Integer = _arRGBValues(index + 1)
Dim r As Integer = _arRGBValues(index + 2)
colour = Color.FromArgb(r, g, b)
Else
' 32bpp
Dim index As Integer = ((ySrc * bmSrc.Width) + xSrc) * 4
Dim b As Integer = _arRGBValues(index)
Dim g As Integer = _arRGBValues(index + 1)
Dim r As Integer = _arRGBValues(index + 2)
Dim a As Integer = _arRGBValues(index + 3)
colour = Color.FromArgb(a, r, g, b)
End If
' Set Pixel
If bmSrc.PixelFormat = Imaging.PixelFormat.Format24bppRgb Then
' 24bpp
Dim index As Integer = ((yDst * bmCrop.Width) + xDst) * 3
arCropValues(index) = colour.B
arCropValues(index + 1) = colour.G
arCropValues(index + 2) = colour.R
Else
' 32bpp
Dim index As Integer = ((yDst * bmCrop.Width) + xDst) * 4
arCropValues(index) = colour.B
arCropValues(index + 1) = colour.G
arCropValues(index + 2) = colour.R
arCropValues(index + 3) = colour.A
End If
'Exit when hit width of the destination bitmap
xDst += 1
If xDst >= bmCrop.Width Then
Exit For
End If
Next
' Exit when hit bottom of the destination bitmap
yDst += 1
If yDst >= bmCrop.Height Then
Exit For
End If
Next
System.Runtime.InteropServices.Marshal.Copy(arCropValues, 0, cropPtr, arCropValues.Length)
' Unlock the bits.
bmCrop.UnlockBits(cropData)
Me.Image = bmCrop
End Sub
-- modified 9-Jun-19 5:35am.
|
|
|
|
|
After further testing I have found this.
It looks like the data return by LockBits() for the source image is not correct.
Below is a portion of data I dumped for Scan0 returned from LockBits().
The test image is 38 x 38 pixels with a single pixel vertical line in column 0.
It was generated in Paint and saved as .jpg.
The Scan0 data shown below shows that the output is being shifted right which is
what the resulting image shows.
Is this some quirk with LockBits() and 24bbp?
Also, I'm still on Windows 7.
Thanks.
Dim bmSrc As Bitmap = Me.Image.Clone() ' The PictureBox image
Dim rect As New Rectangle(0, 0, bmSrc.Width, bmSrc.Height)
Dim _BMPData As Imaging.BitmapData = bmSrc.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmSrc.PixelFormat)
' bmSrc.PixelFormat = Format24bppRgb {137224}
Dim _BMPPtr As IntPtr = _BMPData.Scan0
Dump:
This is the first 2 pixels of col 0 , scanline 0
index(0) - 0 - Col 0 Black
index(1) - 0
index(2) - 0
index(3) - 255 - Col 1 White
index(4) - 255
index(5) - 255
index(x) = 255 from here to next scanline.
This is the first 2 pixels at col 0, scanline 1;
pixel 38 * 3 = 114
index(114) - 0 - Col 0
index(115) - 0
index(116) - 0
index(117) - 0 - Col 1 should be 255
index(118) - 0 - ditto
index(119) - 255
index(x) = 255 from here to next scanline.
This is the first 3 pixels of col 0, scanline 2;
pixel 76 * 3 = 228
index(228) - 255 - Col 0 should be 0
index(229) - 255 - ditto
index(230) - 0
index(231) - 0 - Col 1 should be 255
index(232) - 0 - ditto
index(233) - 0 - ditto
index(234) - 0 - ditto
index(235) - 255
index(236) - 255
|
|
|
|
|
It's not the LockBits that's returning what you think is bad data. What's wrong is what you think the good data is.
The stride is not a perfect 38 pixels * 3 bytes per pixel for each line in your image. It's going to be rounded up to the next 4 byte boundary. The Bitmap object has a Stride property that will tell you how many bytes are in each scan line.
|
|
|
|
|
Wow, I knew that. I wrote some code some 'years' ago in c++ to manipulate bitmaps
with rotation and flipping. Forgot all about it.
Thanks for pointing that out. It's starting to come back to me.
|
|
|
|