|
Hi,
i have below short code in C#
public delegate void MsgEventHandler(object sender, ChatEventArgs e);
public static event MsgEventHandler ChatEvent;
private void Message(ChatEventArgs e)
{
MsgEventHandler temp = ChatEvent;
if (temp != null)
{
foreach (MsgEventHandler handler in temp.GetInvocationList())
{
handler.BeginInvoke(this, e, new AsyncCallback(EndAsync), null);
}
}
}
and when we translate in vb.NET
Public Delegate Sub MsgEventHandler(ByVal sender As Object, ByVal e As ChatEventArgs)
Public Shared Event ChatEvent As MsgEventHandler
Private Sub EmergencyMessage(ByVal e As ChatEventArgs)
Dim temp As MsgEventHandler = ChatEvent
If temp <> Nothing Then
For Each handler As MsgEventHandler In temp.GetInvocationList()
handler.BeginInvoke(Me, e, New AsyncCallback(AddressOf EndAsync), Nothing)
Next
End If
End Sub
but i have error, Saying ChatEvent is an event and can not be called directly.Use a 'Raise Event' statement to raise an event.
can u help me to figure it out from c# to vb.net?
thank you
regards
Sri
|
|
|
|
|
I think if you google Raise Event, you'll see the correct syntax.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Two ways to get the correct syntax.
1 - Read the documentation or search with the error message.
2 - Compile your C# application, open the assembly using reflector and change language to VB.NET.
|
|
|
|
|
Thanks Navneeth,
Can you please expline how to do this. I am new to vb.net. Please.
|
|
|
|
|
Hi whats the equivalent to below code in vb.net
string culture = ((((Range)_ws.Cells[2, (int)ExcelColumnIndexEnum.CultureColumn]).Value2 != null) ?
((Range)_ws.Cells[2, (int)ExcelColumnIndexEnum.CultureColumn]).Value2.ToString().Trim() : string.Empty);
I tried to convert using a tool available in developerfusion that gives me
Dim culture As String = (If((DirectCast(_ws.Cells(2, CInt(ExcelColumnIndexEnum.CultureColumn)), Range).Value2 IsNot Nothing), DirectCast(_ws.Cells(2, CInt(ExcelColumnIndexEnum.CultureColumn)), Range).Value2.ToString().Trim(), String.Empty))
but when i paste in vb editor it shows error.
ExcelColumnIndexEnum is an enum and codes are as.
Imports System
Imports System.Collections.Generic
Imports System.Text
Public Enum ExcelColumnIndexEnum As Integer
CultureColumn = 1
OtherColumn=2
...
End Enum
please help
|
|
|
|
|
This is horrible code, why would you want to convert it ? What error does it show ? I think the If should be Iif, then I think it might work.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I think the error is he is posting C# code into a Visual Basic .Net project...
and yeah, that should be IIF as well.
|
|
|
|
|
Hi,
I'm developing a cybercafe app. and i need to detect printing process from other aplications(Word,Acrobat,...)
I need to send the job to any printer and select if it may be in color or BW.
User doesn't use printer properties directly from its application(word,excel,...). He clicks on printing button directly.
My trouble is catch this action to force him to show the destination printer and job color mode.
I've been working with system.printing namespace to control the spooler:
- When a new job arrives, I stop it. I obtain information about pages, printer,... but if I change any parameters like coloroutput property, it has no efect on the job when I resume it to finish the printing process (restart the job fails too)
Any Idea ?
Regards
|
|
|
|
|
Once you start a print job, it cannot be changed. The spooling data is specifically for the target printer and is written with the parameters chosen in mind. Once the job starts, it's too late to make any changes. The only thing you can do is pause or cancel the job.
|
|
|
|
|
After reading Dave's reply, it has occurred to me that you might be able to create a new print job using those parts from the original that you want to retain and the new ones that you want to use then deleting the original.
I have no idea how you would do that but if it were me, that is what I would explore.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
You could create a Virtual Printer (like those that create PDF file), and set it as the default printer. The virtual printer could then decide how to handle the print job.
I am intending to write a similar Virtual Printer, but for processing emails. I cannot tell you how to start, because I am that stage myself.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Hello,
I have binded a textbox to a field inside a table in the dataset in design time. Does it mean that whenever a validation or a property change occurs on this textbox, The field in the table also gets updated? How to add a new row inside a table and also update the changes in database. If you give me a brief sample code, I would really appreciate it.
I am asking it to you because It has been quite long time I quit working on development and I forgot the methods.
Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
JUNEYT wrote: I have binded a textbox to a field inside a table in the dataset in design time. Does it mean that whenever a validation or a property change occurs on this textbox, The field in the table also gets updated?
If I understand this question correctly, yes, it does.
JUNEYT wrote: How to add a new row inside a table and also update the changes in database.
How do you have your datasource setup? What objects are you using? What does the code look like that sets them up and does the binding?
|
|
|
|
|
Hi,
I am using scriptlet control in my project. When the project is in run mode it works fine. After deploying the project scriptlet control is not working.
Pls help me in this regard
|
|
|
|
|
It's impossible to help you since "it doesn't work" does not supply sufficient information to tell you anything useful. What is the expected behavior? How are you testing this? What isn't happening? What IS happening? ...
|
|
|
|
|
I created one html file that file should view through scriptlet control. Before deploying the project it works fine
After deploying the project only the scriptlet is not working.
I think that the corresponding dll is not there in my deployed application. Here i am sendig my code
Private Sub btnhome_Click()
Unload Me
frmMain.Show
End Sub
Private Sub Form_Load()
Scriptlet1.Visible = False
MMControl1.fileName = App.path & "\Time Line1.mpg"
MMControl1.hWndDisplay = Picture1.hwnd
MMControl1.Command = "Open"
End Sub
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Stop"
MMControl1.Command = "Close"
End Sub
Private Sub Home_Click()
Unload Me
frmMain.Show
End Sub
Private Sub MMControl1_StatusUpdate()
Dim strMode As String
strMode = ""
Select Case MMControl1.Mode
Case mciModeReady
strMode = "Ready."
Case mciModeStop
strMode = "Stopped."
Scriptlet1.Visible = False
Case mciModeSeek
strMode = "Seeking."
Case mciModePlay
strMode = "Playing."
Scriptlet1.Visible = True
'Scriptlet1.url = "file://" & App.path & "\fish1.html"
Case mciModeRecord
strMode = "Recording."
Case mciModePause
strMode = "Paused."
End Select
Label1.Caption = strMode
End Sub
Private Sub Scriptlet1_onscriptletevent(ByVal name As String, ByVal eventData As Variant)
End Sub
|
|
|
|
|
It is probably the URL for the embedded scriptlet object that is causing problems. You probably have it pointing to the absolute address where you are developing it, which of course no-one else can access.
However scriptlets are not a good design choice.
If you are coding in vb.Net, why not use a custom web control (.ascx) instead. If not then I suggest using an iframe. Scriptlets are only supported by Internet Explorer so useless unless used on an intranet with a company policy enforcing no other browser. When used in the real world a page containing a scriptlet will not work at all for nearly a third of your customers.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
Hi All,
I need some help with customizing an upload.aspx. I have a VB.Net 2005
Winform that has a file picker and a textbox (plus loads of other stuff).
When the user selects a file, I want to upload the file to a server.
This is the command I am using in my Winform to upload the file:
My.Computer.Network.UploadFile(CStr(e.Value), Files_Dir, "user", "password",
True, 100, FileIO.UICancelOption.ThrowException)
Where Files_dir = http://server/upload.aspx
Separately, I've created an upload.aspx page that works fine. When I select
a file or type a filename into the textbox on the upload.aspx page and click
upload, the file is uploaded to the correct directory on the server.
The upload.aspx form is simple with just one textbox and 2 buttons:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transition al.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Upload</title>
</head>
<body>
<form id="frmUp" runat="server">
<div>
<input id="inpFile" type="file" runat="server" /><br/>
<asp:Button id="btn_Upload" runat="server" text="Upload" /><br
/>
<span id="txtMsg" runat="server" />
</div>
</form>
</body>
</html>
And the code behind:
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn_Upload.Click
Dim i As Integer
Dim objFile As HttpPostedFile
Dim strFileName As String
Dim strMessage As String = ""
For i = 0 To Request.Files.Count - 1
objFile = Request.Files(i)
If Len(objFile.FileName) > 0 Then
strFileName objFile.FileName.Substring(objFile.FileName.LastInd exOf("\") + 1)
Try
objFile.SaveAs(Server.MapPath("~/Files") & "/" &
strFileName)
strMessage &= "<span>" & strFileName & " successfully
uploaded</span><br/>"
Catch ex As Exception
strMessage &= "<span>Failed uploading " & strFileName &
": " & ex.ToString() & "</span><br/>"
End Try
End If
Next i
txtMsg.InnerHtml = strMessage
End Sub
So, how do I pass the filename to be uploaded to the upload.aspx page?
(Something like http://server/upload.aspx?filename)??? I know the code
that's in the button click event will work when someone actually clicks the
button, but where do I put the code so that it'll fire when the winform
tries to upload a file? (It seems that the page load event might be ok, but,
is the page ever loaded?)
I don't want the Winform user to ever see the upload.aspx page. I just want
the Winform UploadFile command to use the form to put the file on the
server.
Any help would be greatly appreciated!!
|
|
|
|
|
Write a webservice instead of mucking around with this. It can run on the same site as your webpage, so the files will be on the server with your website.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hi expert
i have created one table in mysql database
the field name is
ex. id,name,address
so i want insert name and address in table by store procedure and get value of id by out parameter.
name is in parameter
address is in parameter
id is out parameter
|
|
|
|
|
Con.Open()
'Transaction = Con.BeginTransaction()
Dim cmd As New SqlCommand("SP", Con)
cmd.CommandType = CommandType.StoredProcedure
cmd.ExecuteNonQuery()
Variable = cmd.Parameters("@ID").Value
'Transaction.Commit()
Con.Close()
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
That's great, if only it would work.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
pauleeece correct me if ,their is any mistake
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
When you add your parameters to the code for the proc, make sure you create the parameter explicitly, then add it to the list. That way, you can also set the Direction property ( from memory ) to specify it's an Out parameter. Then check the value on that variable after calling the procedure.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks,
Yes you are right , like this
cmd.Parameters.Add(New SqlParameter("@ID", SqlDbType.Int, 9, ParameterDirection.Output, False, 18, 0, "ID", DataRowVersion.Current, CInt(mCls.EM_ID)))
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|