|
You can't store multiple values in an Integer.
This is just the syntax you use when declaring arrays.
i.e.,
Dim i() As Integer
or
Dim i As Integer()
The parenthesis pair after either the identifier or the type indicates that it's an array of Integer, not a single Integer.
David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
|
|
|
|
|
Zaegra wrote: how I can store multiple values
Dim MyMixedValueArray() As Object
or
Dim MyMixedValueArray As Object()
My advice is free, and you may get what you paid for.
|
|
|
|
|
I agree with David Anton.
Example:
'Declare the array:
Dim myIntArray(2) as Integer
myIntArray(0) = 9
myIntArray(1) = 8
myIntArray(2) = myIntArray(0) - myIntArray(1) 'The value becomes 1 (9 - 8)
That's how it's used.
-Ray
|
|
|
|
|
Hi all,
Currently i am facing a problem when i try to insert rows in a table dynamicly. i using vb.net 2008 with mssql express 2008.here are the details of my codes
USE [database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create PROCEDURE [dbo].[TestSp]
(
@name nvarchar(50),
@tb varchar(200)
)
AS
BEGIN
SET NOCOUNT ON;
execute ('insert into ' + @tb +'(xname)values(@name)')
END
exec testsp 'testtable1','Abcxyz'
Error: Msg 137, Level 15, State 2, Line 1
Must declare the scalar variable "@name".
please help me.
rmshah
Developer
|
|
|
|
|
Notice how you included the table name in the SQL string, do the same for the @Name value as well.
execute ('insert into ' + @tb +'(xname)values(' + @name +')')
Also use pre tags when posting code - easier to read
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
output the first 10 prime number
gift
|
|
|
|
|
I know how to do that one: Console.WriteLine("2 3 5 7 11 13 17 19 23 29")
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
OK, now do the first ten Happy Primes!
All Right, I will...
7, 13, 19, 23, 31, 79, 97, 103, 109, 139
------------------------------------
"Possessions make you poor, wealth is measurable only in experience."
Sun Tzu 621BC
|
|
|
|
|
13 is not and never will be a happy prime number
TonyMac
|
|
|
|
|
I'm happy with 13
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
I have to say, however, that my reasoning for 13 being unhappy is in no way scientific.
TonyMac
|
|
|
|
|
tonym001 wrote: the day the Knights Templar were slaughtered
I don't know them, the only knights I know say ni ny.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Friday, May 15, 2009 5:25 PM
|
|
|
|
|
nee not ni
TonyMac
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I always understood that it was because there were thirteen at the last supper.
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.”
|
|
|
|
|
You might want to look into the sieve of Eratosthenes, and if you wanted to go a little further, throw wheel factorisation into the mix
|
|
|
|
|
I have multiple datasets accessing the same info in the DB. I did this to be able to select specific records based on certain criteria. When I update info in one dataset I get errors about matching records when my dataset.update is called. I am assuming this is because there is conflicting information in another dataset that I am not updating??? Should I be using multiple sql queries on 1 dataset to accomplish the same thing, or is there code I can write that would update all datasets at the same time?
|
|
|
|
|
Okay, this is just too horrible to even want to try and steer in the right direction.
So let's take one BIG step back:
The DataSet is (in a sense) an interface between your logic (code), your data(base) and your GUI. It is NOT a filter.
The basic sequence of events is thus:
1. A query gets the required data from the database. This should already filter as much as possible.
2. The returned result is stored in a (single) dataset.
3. You connect the dataset to your GUI. For example a dataview, or a form with text boxes, or something like that.
4. You write code for any necessary filters, you want the user to be able to apply, such that it is only filtered in the GUI.
5. The user edits and/or inserts and/or deletes data in the GUI. These changes are stored in the DataSet
6. When the user is done, you simply call MyDataSet.Update() and Bob's your uncle.
If you are absolutely sure that there really is no other way than using several datasets on a single database table (which really is a very bad idea), you are going to have to look into row states.
Basically, whenever the user makes a change to a row, the dataset changes the rowstate of that row. In other words, when the user deletes a row, the dataset does not actually delete that row, it just sets the RowState of the row to "deleted".
Another approach would be to update a single dataset, then requery the database and compare the next dataset's changes to that, change any rowstates, update that dataset, etc. However this method (i.e. the path you are on right now) will lead you into to deepest and darkest recesses of a logic jungle, that I fear we will not see you return from.
My advice is free, and you may get what you paid for.
|
|
|
|
|
I want to take today's date, and x number of days, and use the result to setup when next call back happens. How do I take datetime.today and add (x) days to it?
|
|
|
|
|
Gee. I'd wish they would describe how such things can be done and make a document of that; they even could call it "documentation" and tell google it may be relevant to some people.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
if you type either "now" or "today" and the period - you'll see functions like adddays,addhours,addminutes,addseconds,etc.
ex dim dt as datetime = now.adddays(5)
as luc said, this is available anywhere to find like google or vb docs..
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
This code works well but it does not allow me to make change on existed record. for example after I made some change on the data and go to save it it won't allow me. it is a duplicate. I want to be able to make change on existed data and still save. any idea!
Private Sub Save_Click()
On Error GoTo Err_Save_Click
'Dim answer As String
Me.AllowEdits = True
SOCSECNO.SetFocus
If IsNull(Me!InputDate) And IsNull(Me!FirstName) And IsNull(Me!LastName) And IsNull(Me!SocSec) And IsNull(Me!CompanyName) Then
MsgBox "All fields on this form are required"
Exit Sub
ElseIf IsNull(Me!InputDate) Then
MsgBox "An Input Date must be added", vbExclamation
Me!InputDate.SetFocus
ElseIf IsNull(Me!FirstName) Then
MsgBox "First name must be added", vbExclamation
Me!FirstName.SetFocus
ElseIf IsNull(Me!LastName) Then
MsgBox "A Last name must be added", vbExclamation
Me!LastName.SetFocus
ElseIf IsNull(Me!SocSec) Then
MsgBox "A Four Digit SS# must be added", vbExclamation
Me!SocSec.SetFocus
ElseIf IsNull(Me!CompanyName) Then
MsgBox "A Company Name must be added", vbExclamation
Me!CompanyName.SetFocus
ElseIf DCount("*", "[NOC]", "[LastName]= '" & Me![LastName] & "' And [FirstName] = '" & Me![FirstName] & "' And [SocSec] = '" & Me![SocSec] & "'") > 0 Then
Beep
MsgBox "This first and last name already exists in the database. Please check that you are not entering a duplicate constituent before continuing.", vbOKOnly, "Duplicate Value"
Cancel = True
Else
'ElseIf Form.Dirty = True Then DoCmd.RunCommand acCmdSaveRecord
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
MsgBox "Record is asved!"
End If
|
|
|
|
|
You should have another stored procedure that updates existing records based on their ID. It appears as though you're calling a stored procedure that creates new records, thereby trying to duplicate existing information.
|
|
|
|