|
mind if i suggest some VB6 alternative - i've yet to master .net so i don't really know if this works, but...
in vb6 i would do this
If formWhatever.Visible = True Then
Msgbox "Form already visible!"
Else
formWhatever.Show
End If
|
|
|
|
|
That won't work in VB.NET because Forms work VERY differently than they did in VB6. In VB6, every form was already instantiated and visible from anywhere in your code. This is no longer the case in VB.NET since forms are actually classes and you have to instantiate them yourself.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Sir/Madam
Thanks a lot .It is working very fine.
Thanks and regards
Pankaj(India)
|
|
|
|
|
Sir/Madam,
I am trying to make a program using crystal reports in vb.net 2005.
The format of the crystal reports will be displayed in three rows for the particular employee (First row will denote the login in time , Second row will denote the logout time , and the third row will denote the total hours worked.) all these details will come under the days of selected month.The crystal reports will contain columns from 1 to 30 or 1 to 29 or 1 to 28 according to the no of days in the selected month.
Like in first column named 1 (1 is the first day of the month will describe the log in details , log out details in the second row and total hours in the thirs row.)
If somebody may please send any link .I am in urgent need of the code.
Please help.
Thanks and Regards
Pankaj Garg
(India)
Urgent answers will be appreciated.
|
|
|
|
|
amaneet wrote: Urgent answers will be appreciated.
Don't say "urgent". It's just plain rude. Notice how no one replied for over a year. Urgent doesn't work well around here.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
How would I declare and array of structure so that it's visible in my class.
This is in my declaration section
Structure passenger
Public passName As String
Public passAdd As String
Public passPhone As String
Public SeatNum As String
End Structure
Public passengers(15) As passenger
When I try to access passengers(0).passName in a sub, I get an error that says "Object reference not set to an instance of an object."
So how do I declare it so that my whole class can see it?
Thanks
Tom Wright
tawright915@gmail.com
|
|
|
|
|
When you create an array of structures, they are all initalized to zero. That means that all the string references in the structure are null (Nohting in VB). If you try to use a string that doesn't exist, you get that error message.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Okay, I think I was trying to do
private mypassenger(15) as new passenger
in my declaration section. However I get a compile error that says you cannot use te new operator on an array.
BBBBUUUTTT now I see what I am doing wrong.
I'll try it out and see what happens.
Thanks
Tom
Tom Wright
tawright915@gmail.com
|
|
|
|
|
See this[^] thread for an explanation of what's going on.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: See this[^] thread for an explanation of what's going on.
I thought I saw the same kind of problem going on earlier
If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa
|
|
|
|
|
I have a form that is TransparencyKey is set to White and the background is set to white and it comes out transparent, but then I have 2 pictureboxes that have a transparent image(an image with a transparent background), but it takes the background of the form, instead of the desktop. And I do have the me.allowtransparency = true. Does anyone have an Idea as to how just get the image to show and just the image no background color? I would appreciate any suggestions. Thank You!
|
|
|
|
|
hi,
try to set picture's backcolor = transparent...
Thanks & Regards...
Amit
|
|
|
|
|
I have already have it set that way! But Thank You for you time.
|
|
|
|
|
Hi all,
I just bought a G15 Gaming Keyboard, and ofcourse, I already managed to get something on the LCD (with a .NET Wrapped ).
Anyway, I also found out how to intercept the calls from Media Keys, and now, I want to send some mouseclick to Playa!TraX (Media Player) to Start, Pause, Skip song etc.
But, these mouse clicks need ot be sended on a specific coord IN the Playatrax screen, like the play-button (actually a custom created button control) is on x: 200, y: 140.
Second, the Playa!TraX window is also hidden (it slides away under the taskbar, it's called docking).
Third, the current window may not lose focus or something, so switching to playa!trax, moving the mouse to the play-button and click, and then go back to your last window isn't an option! It has to go smooth and unnoticeable.
You don't have to write the full code for me, but an example on how to send the mouseclicks to a specific coord on a specific window would be much appreciated (like how to specify the coords, and how to send the mouseclick, SendMessage didn't worked for me :S)! I already asked this on MSDN Forums, but it looks like Bill Gates didn't know the answer.
Best Regards,
Lennard Fonteijn
Quote from MoHAA (EA-Games): "You mess with the best, you die like the rest!"
|
|
|
|
|
What does your connection string look like? Hopefully, you've done something like the last example on this[^] page.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave. Thanks for your reply. ok here's the thing. i hope i can explain whats going on. my connection string to best describe is what i see as a predefined one. my connection string comes from settings.settings file from what i've learnt. now even if i create a new connection string in code it doesnt help. please instruct me what the best approach is.
Thanks Davo.
|
|
|
|
|
vbbeg wrote: now even if i create a new connection string in code it doesnt help. please instruct me what the best approach is.
I already have.
If you're using the wizards to add your database objects, uhhhh, all I can say is "Don't!". Write your own database code. It's nearly impossible to support the wizard generated code because it's all over the place and impossible to find.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello everyone,
I'm working on an application using VB.Net and Access. The program will read a text file similar to this -->
IM,CRP-FURT-0044148,D,0,@PROD02;IMAGES\00\00;CRP-FURT-0044148.TIF;2
IM,CRP-FURT-0044149, ,0,@PROD02;IMAGES\00\00;CRP-FURT-0044149.TIF;2
IM,CRP-FURT-0044150, ,0,@PROD02;IMAGES\00\00;CRP-FURT-0044150.TIF;2
IM,CRP-FURT-0044151, ,0,@PROD02;IMAGES\00\00;CRP-FURT-0044151.TIF;2
.. and save it to access database, but I keep getting [ array out of bound error ] & [ object reference not set to an instance of an object ]
code for when click import:
conv1.ShowDialog()
If (Not conv1.convFilePath Is Nothing) Then
Me.theDbConnection = db1.createNewDb
flag1 = db1.importData(Me.theDbConnection, conv1.convFilePath)
End If
If flag1 Then
Try
Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection)
Me.dataGridImgs.DataSource = table1
Me.currentRec.Text = ("1\" & table1.Rows.Count) << objct reference not set error
Catch obj As ObjectDisposedException
MessageBox.Show(obj.Message)
End Try
End If
----------
Function for the text delimiter file
Private Function cnvtIpro(ByVal cnvtFile As String, ByVal outFile As String) As Boolean
Dim flag1 As Boolean = True
Try
Dim reader1 As New StreamReader(cnvtFile)
Dim writer1 As New StreamWriter(outFile)
Dim textArray3 As String() = reader1.ReadToEnd.Split(New Char() {ChrW(10)})
Dim num1 As Integer = textArray3.Length
reader1.Close()
Dim num2 As Integer = 0
Do While (num2 < num1)
Try
Dim textArray1 As String() = textArray3(num2).Trim.Split(New Char() {","c})
If (textArray1.Length > 1) And (textArray1(0).ToUpper Is "IM") Then
Dim textArray2 As String() = textArray1(4).Split(New Char() {";"c})
Dim text1 As String = Me.setOutLine(textArray1(1), Path.GetDirectoryName(cnvtFile), (textArray2(1) & "\" & textArray2(2)), textArray1(2), textArray2(0).TrimStart(New Char() {"@"c}), "0")
writer1.WriteLine(text1)
End If
Catch exception1 As Exception
Dim result1 As DialogResult = MessageBox.Show((textArray3(num2) & " :INVALID"), exception1.Message, MessageBoxButtons.OKCancel, MessageBoxIcon.Hand)
If (result1 = Windows.Forms.DialogResult.Cancel) Then
flag1 = False
Exit Do
End If
End Try
num2 += 1
Loop
writer1.Close()
Catch exception2 As Exception
MessageBox.Show(exception2.Message)
flag1 = False
End Try
Return flag1
End Function
-------
Public Function importData(ByVal dbConnection As OleDbConnection, ByVal importFile As String) As Boolean
Dim flag1 As Boolean = True
Dim text1 As String = Nothing
Dim textArray2 As String() = Nothing
Try
dbConnection.Open()
Dim reader1 As StreamReader = File.OpenText(importFile)
Dim textArray1 As String() = reader1.ReadToEnd.Split(New Char() {ChrW(10)})
Dim num1 As Integer = textArray1.Length
reader1.Close()
Dim num2 As Integer = 0
Do While (num2 < num1)
Try
text1 = textArray1(num2).Trim
If (Not text1 Is "") Then
textArray2 = text1.Split(New Char() {ChrW(1)})
textArray2(1) = textArray2(1).Replace("'", "''")
textArray2(2) = textArray2(2).Replace("'", "''")
Dim stringConCat() As String = {textArray2(0), textArray2(1), textArray2(2), textArray2(3), textArray2(4), textArray2(5)}
Me.theOleDbCommand = New OleDbCommand(String.Concat(New String() {"INSERT INTO tblImages(Bates,FullPath,TiffName,PageBreak,Volume,ImgFrame)VALUES('" & textArray2(0), "','", textArray2(1), "','", textArray2(2), "','", textArray2(3), "','", textArray2(4), "','", textArray2(5), "')"}), dbConnection)
theOleDbCommand.ExecuteNonQuery()
End If
Catch exception1 As OleDbException
Dim text2 As String = ""
If (exception1.ErrorCode = -2147467259) Then
text2 = (textArray2(0) & ": already exists, duplicate bates not allowed")
Else
text2 = exception1.Message
End If
Dim result1 As DialogResult = MessageBox.Show(text2, "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand)
If (result1 = DialogResult.Cancel) Then
flag1 = False
GoTo Label_01A9
End If
End Try
num2 += 1
Loop
Catch exception2 As Exception
MessageBox.Show(exception2.Message)
End Try
Label_01A9:
dbConnection.Close()
Return flag1
End Function
Thanks you for helping out!
|
|
|
|
|
First, I'm not reading through all this junk trying to find out where the error is. Point out on which line the errors occur and keep the code snippets to a relative minimum. You've posted WAY too much.
The error "object reference not set to an instance of an object" is cuased because your trying to use an object that doesn't exist. For example, in your first code snippet, your code is making a couple of very bad assumptions.
Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection)
Me.dataGridImgs.DataSource = table1
Me.currentRec.Text = ("1\" & table1.Rows.Count)
When you call imgs1.fillDataTable(Me.theDbConnection) , did it actually return anything?? If not, then table1 doesn't refer to table, hence you can't call any methods on it, which your doing 2 lines later.
Second, in the Me.currentRec.Text... line, even if table1 points to an actual table object, does it contain any Rows? Probably not.
Check the status of your objects before you try and use them. Maybe something like this:
Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection)
If Not table1 Is Nothing Then
Me.dataGridImgs.DataSource = table1
If table1.Rows.Count > 0 Then
Me.currentRec.Text = ("1\" & table1.Rows.Count)
End If
End If
The error "Array out of bounds" means that you're trying to get at more objects in an array than are actually contained in the array. For example, if there are 10 objects in an array, they're indexed as 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. You're trying to get at index number 10 when it doesn't exist.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: You've posted WAY too much.
Yep, that is why I read it only a quarter of a way through, and then went to different forum
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
Thanks Dave for pointing it out. And yes I'm really sorry about posting too much. It wont happen again.
|
|
|
|
|
I have an object
Public Class Plateobj<br />
Public Order As String<br />
Public Row As String<br />
Public Column As String<br />
End Class
I want to create an array of the Plateobj's
Dim plateinfo() As Plateobj
And then refrence them as follow
plateinfo(0).Order = "One"
But I get the following error "Object refrence not set to an instance of an object"
I guess I am doing something daft, any clues welcome
Ta Very Much
|
|
|
|
|
you still have to initialize the object as follows
<br />
Public Class Plateobj<br />
Public Order As String<br />
Public Row As String<br />
Public Column As String<br />
End Class<br />
<br />
Dim plateinfo() As Plateobj<br />
<br />
'*****<br />
plateinfo(0) = new plateobj()<br />
'*****<br />
<br />
plateinfo(0).Order = "One"<br />
<br />
<br />
|
|
|
|
|
Kevin,
Thanks tried that and still get the same error (on the initalise).
Geoff
|
|
|
|
|
try this
<br />
'declare the array<br />
dim plateInfo() as Plateobj<br />
<br />
'set its bounds<br />
redim plateInfo(10)<br />
<br />
'initialze the array item<br />
plateinfo(0) = new Plateobj()<br />
<br />
'now work with it<br />
plateInfo(0).order = "One"<br />
<br />
|
|
|
|
|