|
waldermort wrote: xlApp.Workbooks(FileName).Close savechanges:=Save
This line doesn't make any sense.
I'm guessing "savechanges" is a member variable. It should be on the next line.
Also, the colon ':' allows you to write 2 lines of code on the same line. It turns 2 lines of code like this...
Dim index As Integer<br />
index = 1
And allows you to do this...
Dim index As Integer : index = 1
I don't think that was your intent. Although the := reminded me of Pascal. Ahhh... memories.
So, did you mean to do this?
xlApp.Workbooks(FileName).Close<br />
savechanges = Save
waldermort wrote: GetCellString = xlSheet.Cells(RowId, ColId).Value
I'm guessing that property "Value" is not returning a float. Otherwise, VB would have converted it to a floating point string for you.
Are there any other properties/functions that you can call?
|
|
|
|
|
|
I stand corrected. I've never seen := in VB before. Must be some kind of special syntax because it's not documented in any of my books.
I'm also thinking that your xlApp.Workbooks(FileName) is not returning a WorkBook object, which is why you're getting an exception.
|
|
|
|
|
Excel Spreadsheets determine the datatype of a column, by looking at
the content of the first few rows. If it determines that the column is text,
then all numeric cells/fields are returned as null and if the column is
determined as numeric, then all text fields are returned as null.
Divya Rathi
|
|
|
|
|
I determined that the function itself is causing the problem. You say that the datatype is determined by the first few rows. The first 2 rows and first column of this file contain text, the rest is composed entirly of floating point numbers. From this function:
Public Function GetCellString(RowId As Integer, ColId As Integer) As String
Dim val As Double
val = xlSheet.Cells(RowId, ColId).Value
MsgBox val
GetCellString = xlSheet.Cells(RowId, ColId).Value
End Function
|
|
|
|
|
My code now looks like this
Public Function GetCellString(RowId As Integer, ColId As Integer) As String
If VarType(xlSheet.Cells(RowId, ColId).Value) = vbString Then
GetCellString = xlSheet.Cells(RowId, ColId).Value
ElseIf VarType(xlSheet.Cells(RowId, ColId).Value) = vbDouble Then
GetCellString = CStr(xlSheet.Cells(RowId, ColId).Value)
End If
MsgBox GetCellString
End Function
It is detecting a double, but it is only converting the numbers before the decimal point.
|
|
|
|
|
How do I get the contents of the current field and row from a datagrid?
I have set up the code to run when I click on a record in the datagrid and this works until you sort the datagrid by clicking on the column headers.
dim test as string
test = TestGrid.CurrentRowIndex
COMPANY.Text = CODE_DataSet.Tables(CODE_TABLE).Rows(test).Item(0)
Any Idesas?
|
|
|
|
|
|
There is an ItemCommand event that fires when you click something in the datagrid
one of the arguments for that event is DataGridCommandEventArgs let's call it "e"
myItemCommand (object sender, DataGridCommandEventArgs e )
{
e.Item.DataItem[0]; /*This a DataRowViewRow*/
}
That is how you access a row in a datagrid.
Please let me know if I missunderstood your question or there's anything else I can help you with.
Greetings,
Felipe
|
|
|
|
|
OK I think I have got what I am looking for with:
Dim MyCell As DataGridCell
Dim MyRow As Integer
Dim MyCol As Integer
Dim MyData As String
MyCell = TestGrid.CurrentCell
MyRow = (MyCell.RowNumber)
MyCol = (MyCell.ColumnNumber)
MyData = CODE_DataSet.Tables(CODE_TABLE).Rows(MyRow).Item(MyCol)
COMPANY.Text =MyData
This will work as long as there is data in the cell I clicked on.
How do I test for NULL?
What variable type do I need to set MyData so I dont get a compiler error
"Cast from type DBNull to type String in not valid"
|
|
|
|
|
IF IsDBNull(MyData) Then
COMPANY.Text=""
Else
COMPANY.Text=MyData
End IF
!alien!
|
|
|
|
|
|
Can you show the settings for the adapter under Button1_Click?
|
|
|
|
|
Hey Felipe thanks for your response...
I'm not quite sure what you mean by your question? I can see all the properties for my adapter...
|
|
|
|
|
Excume, but I don't see your command, or connection? where is you data comming from?
|
|
|
|
|
Oh, it is coming from my dataset object SQL server. Here is my connection:
Provider=SQLOLEDB;Data Source=main;Integrated Security=SSPI;Initial Catalog=SpringBooking
|
|
|
|
|
That's OK but I what I need is too see where in your code you are setting this code, your command will help too. But as I already said I need to see in which event and what code you have there to make this works...
|
|
|
|
|
I am trying to pull out info with an SQL statement, and order it by date before it arrives at my datagrid.
sComm += "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.Date FROM Fixtures WHERE (Fixtures.HomeTeam ='" + TName + "' or Fixtures.AwayTeam = '" + TName + "')ORDER BY Fixtures.Date"
It keeps giving me the error:
Syntax error (missing operator) in query expression 'Fixtures.DateSELECT Fixtures.HomeTeam'.
Cheers.
|
|
|
|
|
Ok, let's try first with everything hardcode, can you this pls:
" SELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.[Date] "+
" FROM Fixtures WHERE (Fixtures.HomeTeam =' TName ' OR Fixtures.AwayTeam = ' TName ' ) "+
" ORDER BY Fixtures.[Date] "
If this works then you have data problem a not..
|
|
|
|
|
I am sooooo dumb. Do you know what my problem was. I had messed about with the button that called the fuction. And I forgot to remove something, and it was calling the fuction twice.
Which is why I was getting "Syntax error (missing operator) in query expression 'Fixtures.DateSELECT Fixtures.HomeTeam'."
'Fixtures.DateSELECT Fixtures.HomeTeam'."
Because this..^ is where the first call ends and the other begins.
DOH'
Thanks anyway, its working now.
|
|
|
|
|
My first question has to be, what is in sComm before you this assignment. You are concatinating the select command to the value in sComm, so if sComm contains "Fixtures.Date", then you will end up with
"Fixtures.DateSELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.Date FROM Fixtures WHERE (Fixtures.HomeTeam ='" + TName + "' or Fixtures.AwayTeam = '" + TName + "')ORDER BY Fixtures.Date"
and of course this is not a proper sql command.
I would suggest changing
sComm += "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.Date FROM Fixtures WHERE (Fixtures.HomeTeam ='" + TName + "' or Fixtures.AwayTeam = '" + TName + "')ORDER BY Fixtures.Date"
to
sComm = "SELECT Fixtures.HomeTeam, Fixtures.AwayTeam, Fixtures.Date FROM Fixtures WHERE (Fixtures.HomeTeam ='" + TName + "' or Fixtures.AwayTeam = '" + TName + "')ORDER BY Fixtures.Date"
Hope this helps.
Roy.
|
|
|
|
|
I want to merge 6 pdf files to a single pdf file. i am
working with vb.net, can u please suggest any method
to achieve this using vb.net, pls help me
|
|
|
|
|
I want to have basic knowledge of password hacking , the logic involved , the concept involved behind the hacking . if any one can provide me with a sample code i will be very greatfull.
Thank you
|
|
|
|
|
I hope nobody gives you a serious answer to this, as the subject is not one that I think is accepable on this forum.
There are many many resources online for this sort of thing, CP is not one of them.
|
|
|
|
|
<br />
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
Dim LocationOfOsamaBinladen as string<br />
Dim OsamaBinladensPasswordToBankAccount as string<br />
<br />
LocationOfOsamaBinladen = FindOsamaBinLaden(try-hard)<br />
OsamaBinladensPasswordToBankAccount = GetOsamaBinLardensPassword(try-even-harder)<br />
<br />
SendPasswordTo("KiloDunse**DK**")<br />
SendLocationTO("U.S Goverment")<br />
<br />
End Sub<br />
<br />
<br />
Private Function FindOsamaBinLaden(level-of-commitment) as String<br />
...<br />
End Function<br />
<br />
Private Function GetOsamaBinLardensPassword(level-of-commitment) as String<br />
...<br />
End Function<br />
Any questions?... don't ask me!
Programming is like Mathematics… you take ONE step at the time!
|
|
|
|