|
I haven't, anyway, using the Printer object is fairly simple.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I was aware of this possibility, what I don't get is, why would you do it this way ? How does this create a different object to the one in the VB toolbox ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi all,
I am trying to assign values to my array but i got an error [Object variable or With block variable not set.] May i know where i have gone wrong. Below is my codes. I hope you could assist me.
Thanks!!
Dim d As Integer = 1
Dim seq1 As Integer
Dim seq2 As Integer
Dim strseq1 As String
Dim strseq2 As String
seq1 = tb_seq1.Text.Length
seq2 = tb_seq2.Text.Length
strseq1 = tb_seq1.Text
strseq2 = tb_seq2.Text
'Loop to create array
Dim i, j As Integer
Dim F As Array
For i = 0 To seq1 - 1
F(i, 0) = d * i
Next
For j = 0 To seq2 - 1
F(0, j) = d * j
Next
|
|
|
|
|
someone_blank wrote: Dim F As Array
F = Nothing at this point
someone_blank wrote: F(i, 0) = d * i
So this will blow up.
You need to create the array with new. You'd do better to create an int array, I'd never create an instance of the Array class, that sucks. ArrayList, or List if you have VB 2005, is even better.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
Thank you very much for your help.
Samantha
|
|
|
|
|
As stated by Chris, you have to use new to create instances of the arrays. Moreover, it seems you have to use jagged arrays, since, I think, seq1 , seq2 may hold different values. Look at the following MSDN sample [^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello all!
i am unable to load .dsr(designer) files in vb6-Sp6.
Is it necessary to install crystal reports on my machine to work with .dsr files.
When I run VB6 and try to start a new data project I get an error to refer to datarpt.log for details - this is what the log says:
Line 2: Class {78E93846-85FD-11D0-8487-00A0C90DC8A9} of control DataReport1 was not a loaded control class.
Line 0: The file C:\bern\visbas60\Template\Projects\DataRpt.Dsr could not be loaded.
It's VB6-SP6 (brand new fresh install) - Windows XP
Any ideas?
Plz Help
Thanks!
|
|
|
|
|
Without installing Crystal Reports, how do you expect to edit one of it's Designer files?
That's the problem you're running into. Kind of like trying to open a Word document on a machine that doesn't have Word installed on it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am having trouble getting VB to interact with a MySQL server, which was setup for the purpose of keeping track of points for members of a group. The application is to display a DataGridView of an already created table which is on the MySQL server. The members would edit the table on the DataGridView, and Add or Remove a member based on a button command.
What I have read is that, by using XML, it is possible to simply connect to the database, collect the table required to display, and then disconnect (also for updating the altered data). However, since I am unable to connect to the database, the single-form layout which I had designed doesn't work. I am unable to get this to work, and have tried for weeks.
I am very lost and slightly frustrated at this. I have read every online tutorial which I can find, even other forums, etc. And still...nothing Any help will be greatly appreciated.
|
|
|
|
|
Would I be better off using MSSQL and running it from my machine?
|
|
|
|
|
|
I was actually writing it for SQL and not MySQL ><. Thanks a lot. BTW, Do you have any other links like that which give helpful source code?
|
|
|
|
|
how to get process name from a process ID.. that will return a complete process name(e.g YAHOOMESENGER.exe) not that like msdos filename(e.g YAHOOM~1.exe)
-- modified at 1:08 Tuesday 9th January, 2007
|
|
|
|
|
have you tried:
Dim o As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessById(2844)
MsgBox(o.MainWindowTitle & "(" & o.ProcessName & ")")
|
|
|
|
|
Hello everybody, I wrote the following code snippet to establish a TCP Listener – Client connection. I use a state machine to loop this sub in a thread so that it can continuously receive data from the client.
But there are few problems that I don not know how to handle.
First, if a client is already connected to the TCP listener and the client closed this connection at the remote side, how can I detect this connection loss? For example, I use the HyperTerminal to create a WinSock connection to TCP listener and disconnect it in the HyperTerminal.
Second, how do I handle multiple connections simultaneously?
I do appreciate your help.
<br />
Public Sub socketHandler()<br />
Dim _HostSocket As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP)<br />
Dim _TcpListener As New TcpListener(IPAddress.Parse(getLocalIP), Integer.Parse(TextPortListen.Text))<br />
<br />
Try<br />
<br />
While True<br />
<br />
Select Case sockStatus<br />
<br />
Case socketStatus.SOCKET_IDLE<br />
'does not do anything but wait<br />
<br />
Case socketStatus.SOCKET_STOP<br />
_TcpListener.Start()<br />
sockStatus = socketStatus.SOCKET_LISTEN<br />
<br />
Case socketStatus.SOCKET_LISTEN<br />
<br />
If _TcpListener.Pending = True Then<br />
_HostSocket = _TcpListener.AcceptSocket<br />
sockStatus = socketStatus.SOCKET_CONNECTED<br />
End If<br />
<br />
Case socketStatus.SOCKET_CONNECTED<br />
<br />
If _HostSocket.Poll(1, SelectMode.SelectRead) Then<br />
' _HostSocket has data to be read. <br />
' Call the Socket Available method on _HostSocket; <br />
' assign the return value (Bytes available) to an integer variable. <br />
Dim numBytes As Int32 = _HostSocket.Available<br />
' Instantiate an array of Bytes which is the size of the <br />
' number of Bytes available. <br />
Dim Data(numBytes) As Byte<br />
' Call the Socket Receive method. <br />
' Receives data from a connected Socket. <br />
_HostSocket.Receive(Data)<br />
' Convert the Byte array received into a String <br />
SetText(Encoding.ASCII.GetString(Data), TextRxData)<br />
End If<br />
<br />
Case socketStatus.SOCKET_CLOSING<br />
<br />
If _HostSocket.Connected Then<br />
_HostSocket.Close()<br />
End If<br />
_TcpListener.Stop()<br />
sockStatus = socketStatus.SOCKET_CLOSED<br />
<br />
<br />
Case socketStatus.SOCKET_CLOSED<br />
'the current socket connection is closed. set to idle status<br />
sockStatus = socketStatus.SOCKET_IDLE<br />
End Select<br />
<br />
End While<br />
<br />
Catch ex As Exception<br />
MsgBox(ex.Message.ToString)<br />
End Try<br />
<br />
End Sub<br />
-- modified at 22:11 Monday 8th January, 2007
|
|
|
|
|
I'm just learning VB, (a nug) I'm told that msdn can be very helpful.
is msdn a "redistributable"? I'm trying to find it, not having much luck as I'm not finding anything that is called Just "Msdn" Help? J.Paul Ghetty
|
|
|
|
|
You won't find any VB6 help in MSDN. VB6 has been obsolete for about 5 years and unsupported by MS for a fair while now. Why are you learning it ? If you want to learn to program for anything other than a laid back hobby, VB6 is a bad idea.
MSDN comes on CD with visual studio, unless you download a free version ( VB Express Edition is what I'd be recommending to you ). It's also a website - msdn.microsoft.com[^].
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Any help would be appreciated.
I am trying to design my form to display the data using a Selected Value from a listbox. I set the lbShop.SelectedIndexChanged event to refresh the datagrid when a new value is selected. The variable SShop1 is changed correctly as each item in the listbox is selected, but the datagrid will not refresh using the SQL Select string. What I need is the new SQL Select command to run with the user selected variable, clear the datagrid, and display the data from the new SQL string.
Private Sub frmAllOpenbyShop_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cnn.Open()
reader = dr5.ExecuteReader()
While reader.Read()
values.Add(reader.Item("Shops").ToString())
End While
lbShop.DataSource = values
reader.Close()
Try
'Attempt to load the dataset.
Me.loadDoc()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
End Sub
*******************************************************************************
Public Sub dadapt1()
SShop1 = lbShop.SelectedItem
DAdapt.SelectCommand = New SqlCommand
DAdapt.SelectCommand.CommandType = CommandType.Text
DAdapt.SelectCommand.Connection = cnn1
DAdapt.SelectCommand.CommandText = "Select SystemName, Shop, ActionTaken, TaskNotes, Symptoms, TroubleShooting, Conclusion FROM Workorders WHERE TaskNotes LIKE '" & SShop1 & "' ORDER BY Shop"
End Sub
*******************************************************************************
Public Sub loadDoc()
Me.dadapt1()
Try
dsSearch2.Clear()
DAdapt.Fill(dsSearch2)
Catch ex As SqlException
End Try
grdWorkorders.DataSource = dsSearch2
End Sub
*******************************************************************************
Private Sub lbShop_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbShop.SelectedIndexChanged
grdWorkorders.Refresh()
Me.loadDoc()
End Sub
LWhite
|
|
|
|
|
If you want to do a LIKE query, you need to put the wildcards in, otherwise just use =.
This is not production quality code, a SQL injection attack will perform whatever SQL the malicious user wants to run on it.
Haev you stepped through to see how the code is being executed ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thank you, I replaced the LIKE with = as I didn't need a wildcard search anyway. I will have to look at tightening the code to protect from attack. I stepped through the code and find that if I leave the SShop1 variable = nothing, I get my entire database, as expected, but when I try to set the variable to = a selection from the listbox, I get nothing displayed, just an empty datagrid. This is the line I rem'd out to get a default variable of nothing: SShop1 = lbShop.SelectedItem
Thank you for responding to my question.
Larry
LWhite
|
|
|
|
|
I want to be able to move the minimized form. not change the location for when it restores. I want to minimize it with a left property of 190.
Jason Holland
Stockroom Manager
AE&C Services
|
|
|
|
|
You don't have access to that. The MdiClient control controls the position of minimized (iconed) windows.
Why do you want to do this anyway?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello everyone.
I've read several articles on the internet in trying to figure this out; however, those article seem a bit over my head apparently and I can't seem to find a code example that is simple and to the point to implement.
I'm coding a password manager program in vb 2005. All that is left to do is obtain a password from the user the first time they start the program, and use that password as the encryption key in creating the file that will hold the data from the listview control.
For now, the login form is simply taking the password the user enters and encrypting it inside a separate file for now as you will see below - the file itself is not encrypted. I have all the forms complete and the listview data is writing to a currently unencrypted file for now. I just want to make it all one file with the user password being the key to encrypt it all.
Here is the login code I'm using if we can somehow modify it to do what I'm looking for:
If txtUserPsw.Text = txtPswVerify.Text And Me.txtPswVerify.Text.Length >= 8 Then
Try
' Obtain a FileStream object.
Dim aFileStream As New FileStream(AppPath(False) & "\passsafe.bin", FileMode.Create)
' Obtain a BinaryWriter object.
Dim aBinaryWriter As New BinaryWriter(aFileStream)
' Encrypt the new password and binary write to a binary file.
aBinaryWriter.Write(EncryptPassword.EncryptString(Me.txtPswVerify.Text))
' Close the FileStream and the BinaryWriter objects.
aFileStream.Close()
aBinaryWriter.Close()
' Message user.
MessageBox.Show("Password was encrypted and saved. Don't forget it!")
'Display Main form (Frmlogin)
Dim safe As New frmSafe
'Hides login form
Me.Visible = False
safe.ShowDialog()
'disposes login form on exit of main form
'Application.Exit()
Me.Close()
Catch ex As Exception
' Message user.
MessageBox.Show("Password was not saved. ERROR: " & ex.Message)
End Try
End If
Thanks everyone!
Sincerely,
Harold
|
|
|
|
|
Im trying to print a document in landscape. But it seems my program only print in regular orientation, that is the on ive set in the printer driver under Start->Settings->Printer and faxes.
Im using the QueryPageSettings sub when it prints and set e.PageSettings.Landscape = True but nothing happens.
Anyone got same problems or have any ideas?
Thanks
|
|
|
|
|