|
"The way I read your code at the moment is If a user clicks on a Row and Cell 0 (checkbox) is Checked, then the contents of Cell 2 are moved into Cell 1 otherwise you clear the contents of Cell 1"
yes that what I want to do
" Are you using mouse clicks to Check and UnCheck the checkbox in Cell 0 or is it being populated by a data source?"
yes I use the mouse clicks to Check and UnCheck the checkbox in Cell 0
|
|
|
|
|
I loaded the code below and it works, it's a little simplistic however by playing around with it I'm sure you can improve your skills by making adjustments.
Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Click
Dim pRowNo As Integer
pRowNo = Val(DataGridView1.SelectedCells(0).RowIndex.ToString())
If DataGridView1.Rows(pRowNo).Cells(0).Value = 1 Then
DataGridView1.Rows(pRowNo).Cells(1).Value = DataGridView1.Rows(pRowNo).Cells(2).Value
Else
DataGridView1.Rows(pRowNo).Cells(1).Value = ""
End If
End Sub
|
|
|
|
|
Hi John thank you for standing with me in this code
I got this error
" Operator '=' is not defined for type 'DBNull' and type 'Integer'."
DataGridView1.Rows(pRowNo).Cells(0).Value = 1
I tried to do something like this
DataGridView1.Rows(pRowNo).Cells(0).Value.Tobit = 1
but I still get the same error notice that I'm working on Visual basic Studio 2010 is ther any difference
|
|
|
|
|
You just have to test if the value is a null first. Using a IsDBNull function call.
http://www.freevbcode.com/ShowCode.asp?ID=5810
or
http://msdn.microsoft.com/en-us/library/tckcces5%28v=vs.71%29.aspx
|
|
|
|
|
|
Please check this link.
It is a tool allow you to convert between C# and VB.Net
Link
|
|
|
|
|
actually how to write this code correctly???
other txtsms not showing..just txtsms.text = seat booked
it just show Seat booked: seat1
only seat 1 show instead of 4 seats..plss help..
For i = 4 To wc
TxtSMS.Text = "Congratulation!! Your ticket succesfully booked. Detail of your tickect:" & vbCrLf & "Cinema: " & Branch & vbCrLf & "Movie title: " & moviename & vbCrLf & "Time: " & timeplaying & vbCrLf
TxtSMS.Text = "Tickect ID: " & randomID & "Pls show your tickect ID to our reception counter to get your tickect. TQ"
TxtSMS.Text = "Seat Booked: " & SplitWord(i).ToString & " "
Next
|
|
|
|
|
You do know that every time you set the value of the Text property it REPLACES the text that is already there, not appends to it, correct?
|
|
|
|
|
ooowwhh.. so how i could write the code to show that all .. actually i know i can use & vbcrlf & "something" something like that...
but my problem is i dont know how to display as this line as you can see on my code before:
"Seat booked: " & splitword(i).tostring
where i = 1 ,2 ,3 and until some number depends on the word count.
for know i only can show only for splitword(1).
i use txtsms.text = txtsms.text & "seat booked: " & splitword(i) but the text "seat booked" also repeated.. so what is the correct code to write??
|
|
|
|
|
Someone else gave you the answer. But, the underlying problem still remains. The problem you ran into a a copmlete lack of experience and very basic knowledge of VB.NET (or any other language). I seriously recommend picking up a beginners book on VB.NET and working through it.
|
|
|
|
|
Something like
TxtSMS.Text = "Congratulation!! Your ticket succesfully booked. Detail of your tickect:" & vbCrLf & "Cinema: " & Branch & vbCrLf & "Movie title: " & moviename & vbCrLf & "Time: " & timeplaying & vbCrLf
TxtSMS.Text += "Tickect ID: " & randomID & "Pls show your tickect ID to our reception counter to get your tickect. TQ"
For i = 4 To wc
TxtSMS.Text += "Seat Booked: " & SplitWord(i).ToString & " "
Next
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
it works..thanx so much...
|
|
|
|
|
Happy to help.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
Hello,
I get the following error in run time.
Error message
Unable to cast from a number, the value must be less that infinity.
My code in vb .net visual studio 11
Form load
Me.Client = New DXProf(Me) --Excetion thrown here---
Me.components = New Container
Dim manager As New ComponentResourceManager(GetType(Form1))
DXFramework.m_Icon = DirectCast(manager.GetObject("$this.Icon"), Icon)
DXFramework.LoadInstance(Me.Client, Me)
End Sub
End Sub
Here is the exception detail.
System.InvalidCastException occurred
Message=Unable to cast object of type 'DXProf' to type 'idt.medical.IDXClient'.
Source=DXPro
StackTrace:
at DXPro.Form1.Form1_Load(Object sender, EventArgs e) in C:\VBDXDCURRENT\Functionional No Errors\DXPro\Form1.vb:line 73
InnerException:
Any help would be appreciated.
Michael
|
|
|
|
|
What the (explitive deleted) is "DXProf"?? It's surely not part of the .NET Framework, so it's VERY unlikely anyone is going to know about it.
If it's a third party lirbary, you're best bet for getting help on this problem would be the people who wrote that library.
|
|
|
|
|
Dave,
Thanks for your info,
I am the only one working on this program. The original author is not with us anymore and I a picking up the pieces. I have so so source code and comments and no documentation either.
DXProf is a component in the app that works with externel .dll's. I personally would not have written it that way. But I have deal with what I have.
Thanks for your help.
Michael
|
|
|
|
|
KireronThunderStone wrote: Message=Unable to cast object of type 'DXProf' to type 'idt.medical.IDXClient'.
This message tells you everything you need to know. You are trying to initialise a idt.medical.IDXClient object from a DXProf object, but the two are not compatible.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
|
From this, and your other responses, I get the feeling you do not really understand inheritance and still have no idea what this error is about. You need to look at your class definitions to see why the two are incompatible.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
|
In case that it was you (or someone of your colleagues) to develop that DXProf component, make sure that it inherits from 'idt.medical.IDXClient ' (which might be an interface).
Actually I'd expect the compiler to complain - is there still some kind of "Option Explicit Off" in that version of VB?
|
|
|
|
|
Bernhard,
Thanks for the info, I am the only one working on this project, the last developer and creator is no longer with us. I having to reconstruct everything with so so source code and no comments or documents to speak of.
In vb 2008 and version 11 there is a few choices of option explicit, so yes I could turn it off. There is also option strict which can be toggled off too.
Now you said to make sure that the DXProf component inherits from idt.medical.IDXClient. Could you give me an example. Yes you are right idt.medical.IDXClient is an interface.
Please help if you can.
And Thanks.
Michael
|
|
|
|
|
Get the source code of DXProf, and change the class statement:
Public Class DXProf
Implements idt.medical.IDXClient
Then you'll likely receive some error messages that DXProf must implement this or that function of property. Just do that. Take care of the exact signature of functions.
|
|
|
|
|
Here is the code i am using for this
Imports System
Imports System.IO
Imports System.Data.OleDb
Imports ADOX
Imports System.Data
Imports OLEDBError
Public Class Main
Private filename As String
Private TexttxtFileContents As String
Private paths() As String = Split(Environment.GetEnvironmentVariable("PATH"), ";")
Private Sub SplitContainer1_Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles SplitContainer1.Panel1.Paint
End Sub
Private Sub HTRADIO_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HTRADIO.CheckedChanged
HTGROUP.Visible = True
HTLTGB.Visible = False
End Sub
Private Sub HTANDLT_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HTANDLT.CheckedChanged
HTLTGB.Visible = True
End Sub
Private Sub HTCONButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HTCONButton.Click
Dim start_dir As String = System.Windows.Forms.Application.StartupPath
Try
With odlgTextFile
' See btnRetriveFileNames_Click for explanations of default values
' for the properties.
' Check to ensure that the selected file exists. Dialog box displays
' a warning otherwise.
.CheckFileExists = True
' Check to ensure that the selected path exists. Dialog box displays
' a warning otherwise.
'.CheckPathExists = True
' Get or set default extension. Doesn't include the leading ".".
.DefaultExt = "dbf"
' Return the file referenced by a link? If False, simply returns the selected link
' file. If True, returns the file linked to the LNK file.
'.DereferenceLinks = True
' Just as in VB6, use a set of pairs of filters, separated with "|". Each
' pair consists of a description|file spec. Use a "|" between pairs. No need to put a
' trailing "|". You can set the FilterIndex property as well, to select the default
' filter. The first filter is numbered 1 (not 0). The default is 1.
.Filter = _
"Database files (*.dbf)|*.dbf|All files|*.*"
.Multiselect = False
' Restore the original directory when done selecting
' a file? If False, the current directory changes
' to the directory in which you selected the file.
' Set this to True to put the current folder back
' where it was when you started.
' The default is False.
.RestoreDirectory = True
' Show the Help button and Read-Only checkbox?
.ShowHelp = True
.ShowReadOnly = False
' Start out with the read-only check box checked?
' This only make sense if ShowReadOnly is True.
.ReadOnlyChecked = False
.Title = "Select a file to open"
' Only accept valid Win32 file names?
.ValidateNames = True
If .ShowDialog = Windows.Forms.DialogResult.OK Then
Try
HTCONDTextBox.Text = .FileName
'Data Copy to GEC-Neplan Folder
Dim FileToCopy As String
Dim NewCopy As String
FileToCopy = .FileName
NewCopy = "C:\GEC-NEPLAN\HT-CONDCUTOR.DBF"
If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)
End If
'HTCONDTextBox.Text = My.Computer.FileSystem.ReadAllText(.FileName)
Catch fileException As Exception
Throw fileException
End Try
End If
End With
Catch ex As Exception
'MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
End Try
End Sub
Private Sub HTPOLEButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HTPOLEButton.Click
Try
With odlgTextFile
' See btnRetriveFileNames_Click for explanations of default values
' for the properties.
' Check to ensure that the selected file exists. Dialog box displays
' a warning otherwise.
.CheckFileExists = True
' Check to ensure that the selected path exists. Dialog box displays
' a warning otherwise.
.CheckPathExists = True
' Get or set default extension. Doesn't include the leading ".".
.DefaultExt = "dbf"
' Return the file referenced by a link? If False, simply returns the selected link
' file. If True, returns the file linked to the LNK file.
.DereferenceLinks = True
' Just as in VB6, use a set of pairs of filters, separated with "|". Each
' pair consists of a description|file spec. Use a "|" between pairs. No need to put a
' trailing "|". You can set the FilterIndex property as well, to select the default
' filter. The first filter is numbered 1 (not 0). The default is 1.
.Filter = _
"Database files (*.dbf)|*.dbf|All files|*.*"
.Multiselect = False
' Restore the original directory when done selecting
' a file? If False, the current directory changes
' to the directory in which you selected the file.
' Set this to True to put the current folder back
' where it was when you started.
' The default is False.
.RestoreDirectory = True
' Show the Help button and Read-Only checkbox?
.ShowHelp = True
.ShowReadOnly = False
' Start out with the read-only check box checked?
' This only make sense if ShowReadOnly is True.
.ReadOnlyChecked = False
.Title = "Select a file to open"
' Only accept valid Win32 file names?
.ValidateNames = True
If .ShowDialog = Windows.Forms.DialogResult.OK Then
Try
HTPOLETextBox.Text = .FileName
'Data Copy to GEC-Neplan Folder
Dim FileToCopy As String
Dim NewCopy As String
FileToCopy = .FileName
NewCopy = "C:\GEC-NEPLAN\HT-POLES.DBF"
If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)
End If
Catch fileException As Exception
Throw fileException
End Try
End If
End With
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
End Try
End Sub
Private Sub NEXT1Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NEXTHCButton.Click
Call Link_Table("HTCON", "HT-CONDCUTOR")
End Sub
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Check Wheter Folder Exists or Not;If Exists Delete and Creat New One
If (System.IO.Directory.Exists("C:\GEC-NEPLAN")) Then
System.IO.Directory.Delete("C:\GEC-NEPLAN", True)
End If
System.IO.Directory.CreateDirectory("C:\GEC-NEPLAN")
Dim cat As New Catalog()
Try
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\GEC-NEPLAN\SHAPE-NEPLAN.mdb")
'MessageBox.Show("Database Created.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch Excep As System.Runtime.InteropServices.COMException
MessageBox.Show(Excep.Message, "Error Database Not Created", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
cat = Nothing
End Try
End Sub
Public Sub Link_Table(ByVal filename As String, ByVal name As String)
'*****************************************************
'Creates a link in our database to the dbf 'filename'
'*****************************************************
'References:
'ADODB ( .Net:ADODB )
'ADOX ( COM:Microsoft ADO Ext 2.8 for DDL and Security )
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Dim con As New ADODB.Connection
'Copy long named files to allow an access connection
If Len(System.IO.Path.GetFileNameWithoutExtension(filename)) > 8 Then
System.IO.File.Copy(filename, System.IO.Path.GetDirectoryName(filename) & "\" & name & ".dbf", True)
filename = System.IO.Path.GetDirectoryName(filename) & "\" & name & ".dbf"
End If
'A connection to the database where you are adding the link
con.ConnectionString = "Data Source=""C:\GEC-NEPLAN\SHAPE-NEPLAN.mdb"";Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1"
con.Open()
cat.ActiveConnection = con
'Get Rid of the old table if it exists
On Error Resume Next ' If the table is not there, ignore the resulting error
cat.Tables.Delete(name)
On Error GoTo 0
' Create the new table.
With tbl
.Name = name
.ParentCatalog = cat
' Set the properties to create the link.
.Properties("Jet OLEDB:Create Link").Value = True
.Properties("Jet OLEDB:Link Datasource").Value = System.IO.Path.GetDirectoryName(filename)
.Properties("Jet OLEDB:Link Provider String").Value = "Dbase IV"
.Properties("Jet OLEDB:Remote Table Name").Value = name
End With
' Append the table to the tables collection of the catalog.
cat.Tables.Append(tbl)
con.Close()
' Clean up.
cat = Nothing
End Sub
End Class
|
|
|
|
|
..and what is the problem with the code? Does it throw an exception? If yes, what does the exception say?
Bastard Programmer from Hell
|
|
|
|