|
Properly written, you don't. If you want to run an .eXE when a user logs in, this is not done as a service, but as a normal executable running out of the Registry's Run key.
|
|
|
|
|
use the sc.exe in the system32 folder. This will allow you to create, name, and assign an exe to a service. This can be easily done in a small batch script shelled out by the vb or in vbscript. A seperate script is not bad, but this does require to either sleep the thread, run another thread during execution of the script
|
|
|
|
|
I want select my form name from combo box and then
list my selected form controlsname in list box
but selecteditem in combobox is a string and control property for string is not valied
please help me
|
|
|
|
|
I can think of two ways. Either use System.Activator.CreateInstanceFrom or have the value member of the combo as the instance of the form.
|
|
|
|
|
please send me a example for this session
|
|
|
|
|
I assume this means you tried using what I told you yesterday, but don't really know much of anything about C# or winforms. Your forms have a Text property which is the title of the window. You can also use GetType().ToString() to get the name of the class. Either way, you really need to read a basic winforms book, so you can understand the answers you're given
you should also consider reading the posting guide - help me is obviously useless as a title, everyone posting here wants help.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian Graus wrote: You can also use GetType().ToString() to get the name of the class.
Could not get this. How can you get the instance of form by the a string variable having its text (I guess this is what he asked) using GetType(). Can you show some example?
|
|
|
|
|
d@nish wrote: How can you get the instance of form by the a string variable having its text (I guess this is what he asked) using GetType().
You don't, that's not what he asked. He asked how to get the open forms, and I said Application.Current.OpenForms ( or something like that ). He's then tried to assign THAT to his combo, instead of getting the strings he wants from there.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi, I've looked in a few places but haven't had much luck in finding what I'm after.
So I have a picturebox on my windows form and it has an image set to it, I also have a bunch of reference files that reference to a bunch of images.
Me.PictureBox1.Image = My.Resources.imgs.image1
That piece of code works.
Now, I tried to databind the picture box to a database so the images would load on the change of a combo box but that got confusing really fast so what I did was created a database and it holds all the image references such as "My.Resources.imgs.image1" but its stored as type varchar(50).
Connecting to the database and retreiving the strings is no problem, that works all fine.
The problem is converting the string to the image reference, it doesn't work. I've tried type casting, I tried using imagelocation rather than image but I want to reference to the resources that is attached to the project.
Can anyone help me with this issue? - Thanks
Here is the full code, incase it helps
Imports System.Data.SqlClient 'before class constructor
Dim SQLStr As String
Private ConnString As String
'after class constructor
'the following is within a sub
ConnString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\statsdata.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
SQLStr = "SELECT imgreference FROM tblImages WHERE (number = " + Me.ComboBox1.SelectedIndex + ")"
Dim SQLConn As New SqlConnection() 'The SQL Connection
Dim SQLCmd As New SqlCommand() 'The SQL Command
Dim SQLdr As SqlDataReader 'The Local Data Store
Dim text As String
Dim img As Image = Nothing
SQLConn.ConnectionString = ConnString 'Set the Connection String
Try
SQLConn.Open() 'Open the connection
SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
SQLCmd.CommandText = SQLStr 'Sets the SQL String
SQLdr = SQLCmd.ExecuteReader() 'Executes SQL Commands Non-Querys only
SQLdr.Read()
text = SQLdr.GetString(0)
SQLdr.Close() 'Close the SQLDataReader
SQLConn.Close() 'Close the connection
'This is where I would change the reference of the image
'E.g. Me.PictureBox1.Image = text - except I have to cast text from type String to type Image
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Somethings wrong!!")
End Try
|
|
|
|
|
So yea, I posted the same query on another forums and they answered the question
The answer is the following ::::
If you look at the designer code of the resource file, you will find the following code
Public Shared ReadOnly Property image1() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("image1", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
However, the coding behind our windows form isn't a namespace, so instead of going straight to resource manager, My.Resources.imgs.ResourceManager
so in the code I had above, you can just go
Me.PictureBox1.Image = My.Resources.imgs.ResourceManager.GetObject(text)
|
|
|
|
|
Hello friends
I have two radio buttons view and insert the view radio button display dropdown box, the dropdown box display the records retrieved from the database and displayed.
(i) The first index is empty and the rest of the index is filled with the retrieved data i need the data to be displayed starting the first index.
(ii) When i switch between the view and insert radio button and back to view radio button the data in the dropdown box is doubled for each of the above mentioned cycle
Code:
-----
Public Class Form1
Dim Conn As SqlConnection
Dim Cmd As SqlCommand
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Conn = New SqlConnection
Cmd = New SqlCommand
Conn.ConnectionString = "Data Source=PERSONAL-A0CC22\SQLEXPRESS;Initial Catalog=personal;Integrated Security=True"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If (StudentId.Text = "" Or Fname.Text = "" Or Lname.Text = "" Or Address.Text = "" Or Mobile.Text = "" Or EmailId.Text = "") Then
Label1.Text = "Fill In All The Fields"
Label1.Visible = True
Else
Conn.Open()
Cmd = Conn.CreateCommand()
Cmd.CommandText = "Insert into student values('" + StudentId.Text + "', '" + Fname.Text + "', '" + Lname.Text + "', '" + Address.Text + "', '" + Mobile.Text + "', '" + EmailId.Text + "')"
Cmd.ExecuteNonQuery()
StudentId.Text = ""
Fname.Text = ""
Lname.Text = ""
Address.Text = ""
Mobile.Text = ""
EmailId.Text = ""
Label1.Visible = True
Label1.Text = "Data Have Been Stored Sucessfully"
Conn.Close()
End If
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
TStudentId.Visible = True
StudentId.Visible = False
Button1.Visible = False
Button2.Visible = True
Button3.Visible = True
Dim i As Integer
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
Conn.Open()
Cmd = Conn.CreateCommand
Cmd.CommandText = "Select StudentId from Student"
da.SelectCommand = Cmd
da.Fill(ds, "Student")
dt = ds.Tables("Student")
For i = 0 To dt.Rows.Count - 1
TStudentId.Items.Add(dt.Rows(i).Item(0))
Next
Fname.Text = ""
Lname.Text = ""
Address.Text = ""
Mobile.Text = ""
EmailId.Text = ""
Conn.Close()
End Sub
|
|
|
|
|
I think the solution to your problem is quite simple, but I cannot be sure because your code snippet is so badly formatted that it is difficult to read.
Next time you post some code please use the 'code block' widget (below the Text: box). Put the cursor on a new line, click the 'code block' and then paste your code between the opening and closing tags. That way all of your formatting etc. will be retained, making it easier for people to read and therefore more likely that you will get a response.
OK, lecture over. To solve your problem, whilst using your existing code, modify your RadioButton2_CheckedChanged method like this:
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
TStudentId.Visible = True
StudentId.Visible = False
Button1.Visible = False
Button2.Visible = True
Button3.Visible = True
Dim i As Integer
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
TStudentId.Items.Clear() '<========================= HERE'S the change, get rid of the old stuff before adding the new
Conn.Open()
Cmd = Conn.CreateCommand
Cmd.CommandText = "Select StudentId from Student"
da.SelectCommand = Cmd
da.Fill(ds, "Student")
dt = ds.Tables("Student")
For i = 0 To dt.Rows.Count - 1
TStudentId.Items.Add(dt.Rows(i).Item(0))
Next
Fname.Text = ""
Lname.Text = ""
Address.Text = ""
Mobile.Text = ""
EmailId.Text = ""
Conn.Close()
End Sub
But I have to ask. Why not just set TStudentId.DataSource to dt, rather than use the For..Next loop as you do?
Another lecture coming up, sorry!
For your own peace of mind, do try to stop using silly member names (da for a DataAdapter, dt for a DataTable), sure you remember what they do now, but in six months you won't. And what are you going to do when you need more than one DataAdapter, use da2 ? Instead of dt, how about StudentIdTable, or tblStudentID, and so on.
Also RadioButton2, what does it do? Again you know now, but in six months?? And more importantly in this case It took me a lot more reading to work out what was going on than it should have done. Give all members and controls (with the possible exception of Labels) sensible descriptive names. How about rbtnShowId for example 'rbtn' tells me it is a RadioButton 'ShowId' tells me that it shows/hides the Id Dropdown, devise your own naming scheme and stick to it.
It will make your life so much easier in future.
Rant over. Sorry again.
Anyway, good luck!
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.”
|
|
|
|
|
Greetings,
I am writing a VB.NET console application that does nothing but read from a SQLServer database and spit out an Excel file. My development box has Windows XP and Office 2003 installed. The target box is running Windows Server 2008 and Office 2007. Everything runs fine on my dev box (of course) but I'm getting this error whenever I run it on the target box: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.
I felt like I've searched the entire Internet looking for a solution but to no avail. Some solutions that specifically mention that CLSID involve ASP.NET configurations and DCOM properties. Since mine is an executable and not a web page, those solutions don't seem to apply. I went ahead and tried anyway, granting the application's User ID specific permissions to the Excel DCOM object, but that didn't fix my problem. I read somewhere that error 80070005 was a permissions error but the application's User ID is a member of the Admins group so I'd think that user has all the permissions it needs.
Here's part of my current code and a note on which line is causing the failure:
Imports Microsoft.Office.Interop.Excel
Public Function fExportToExcel() As Boolean
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim missingValue As Object = System.Reflection.Missing.Value
Try
xlApp = New Microsoft.Office.Interop.Excel.Application <code><<== FAILS HERE</code>
xlBook = xlApp.Workbooks.Add(missingValue)
xlSheet = CType(xlBook.Sheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
xlSheet.Name = My.Application.Info.AssemblyName.ToString
<snip> I've set a reference to the Microsoft Excel 11.0 Object Library in my app. Here are two of it's properties:
Identity {00020813-0000-0000-C000-000000000046}\1.5\0\primary<br />
Path C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\11.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll
I don't quite understand what a CLSID is or how it works. Does it mean anything that my Identity CLSID ({00020813-0000-0000-C000-000000000046}) is different than that in my error message ({00024500-0000-0000-C000-000000000046})?
So is it possible to develop an app using one version of the OS and Office but target a different OS and Office? If so, do I account for those differences in my app or do I have to make some kind of change(s) to the target box? What property or code changes do I need to make? Any help will certainly be appreciated!
Thanks!
Dan
|
|
|
|
|
A CLSID is the id of your COM object. I'd guess the issue is the different versions of Office.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
You're referencing Excel 11 (2003) where your target is Excel 12 (2007). I would have thought backwards compatability would allow you to still reuse the same code for Excel 2007...
|
|
|
|
|
I'd have thought so too. Any idea how the CLSID factors into that?
|
|
|
|
|
Nope, but I did do some poking around, it might have something to do with permissions.
Try granting your application permission to access the office binaries?
|
|
|
|
|
HI
I have a small problem with my application:
The application is a small programme that runs at computer log in, I have made some code to copy the start shortcut to the all-users startup folder.
Here comes my problem: When a new user is logging on to the PC the installer runs and then installs the application again for the new user.
Is there a way to install the application for all users the first time??
Best Jesper
|
|
|
|
|
You only need to install the app once, in Program Files. Then you just need to put its shortcut in Documents and Settings\All Users\Start Menu\Programs.
|
|
|
|
|
hi
I'm working on a webcam application using AVICAP class API available in the Windows operating system using vb.net, I'm facing a problem when I am doing limit to the duration of a capture operation by using the fLimitEnabled and wTimeLimit members of the CAPTUREPARMS structure
I wrote this code:
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CAP_PRAMS As New CAPTUREPARMS()
SendMessage(hWnd, WM_CAP_GET_SEQUENCE_SETUP, Len(CAP_PRAMS), CAP_PRAMS)
With CAP_PRAMS
CAP_PRAMS.fLimitEnabled = True
CAP_PRAMS.wTimeLimit = 5
End With
SendMessage(hWnd, WM_CAP_SET_SEQUENCE_SETUP, Len(CAP_PRAMS), CAP_PRAMS)
SendMessage(hWnd, WM_CAP_SEQUENCE, 0, 0)
SendMessage(hWnd, WM_CAP_FILE_SAVEAS, 0, _
"C:\Video1.avi")
End Sub
ok, the problem is when I run this code it gives me video file with time recorded 0 sec, it is just an image with avi extention
and I want it to be video file with 5 sec time duration
please tell me where is the problem
thnx in advance
|
|
|
|
|
I don't why, but I would try writing 5000 instead of 5.
When you use the timer object, 5000 equals 5 seconds... That could be a reason, however I am not sure.
Hope it helps you!
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
|
Hi everybody, I hope somebody can help me with this.
I've received a VB.NET project, and I must add some functions taken from another VB6 project.
One of these functions, uses the String$ function like this:
strValTemp = String$(1024, 0)
But it seems that VB.NET does not allow me use this function. Is there any other way of doing the same?
Thanks.
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
String$(1024, 0) creates a string 1024 characters long filled with nulls.
Is that going to be too hard in vb7.net?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi,
the string class has a constructor that takes one character and one number; it builds a string using that character count times, which AFAIK is what String$() used to do.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|