vb5prgrmr 143 Posting Virtuoso

GoTo http://www.microsoft.com then there is a navigation and the second from the right is Support. Click that and when the list appears click on MSDN. However, a lot of documentation is geared towards .NET so when you search you will need to add either VB6 or Visual Basic 6.0 to your queries.

Good Luck

vb5prgrmr 143 Posting Virtuoso

See my answer in your other similar thread.

Good Luck

vb5prgrmr 143 Posting Virtuoso

WinZip has this functionality...

http://www.winzip.com/prodpagese.htm

Good Luck

vb5prgrmr 143 Posting Virtuoso

A definition at the top, a Java example, then a VB6 example...

http://compsci.ca/v3/viewtopic.php?p=146070&no=1

Another...

http://www.tek-tips.com/viewthread.cfm?qid=1387082

Good Luck

vb5prgrmr 143 Posting Virtuoso

Hmmm... Something along a card shuffle algorithm...

Option Explicit

Dim NumArray() As Integer

Private Sub Form_Load()
Dim ForLoopCounter As Integer, Temp As Integer, HoldValue As Integer
ReDim NumArray(9) As Integer

Randomize

For ForLoopCounter = 0 To 9
  NumArray(ForLoopCounter) = ForLoopCounter
Next ForLoopCounter

For ForLoopCounter = 0 To 9
  
  'get random number from 1 to 10
  Temp = Rnd() * UBound(NumArray)
  
  'set labels caption
  Label1(ForLoopCounter).Caption = NumArray(Temp)
  
  'check to make sure we need to continue
  If UBound(NumArray) = 0 Then Exit For
  
  'now swap values
  HoldValue = NumArray(UBound(NumArray))
  NumArray(UBound(NumArray)) = NumArray(Temp)
  NumArray(Temp) = HoldValue
  
  'then get rid of used number
  ReDim Preserve NumArray((UBound(NumArray) - 1)) As Integer
  
Next ForLoopCounter

End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

Perhaps those "spaces" you are talking about are actually "tab" characters. Try replacing with vbTab instead of " ".

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, downloaded your project and I see that you are using .NET. This is the "classic" vb forum for versions prior to .net 2k2 (2k3,2k5,2k8,(2k10)). However, what I said before still applies and I think I understand more of what you are asking.

Okay, in classic vb as in .net you can declare a public variable in the general declarations part of a form and then reference it by using...

formname.variablename

via retrieving or setting...

somevariable = formname.variablename

or

formname.variablename = somevalue

just as you would do...

somevariable = DirectoryForm.HayesLabel.Text

Now, as to try to answer your other question...

When a form is hidden and not unloaded everything contained within that form that has been exposed (controls, public variables) are accessible from other forms or modules (don't get confused here, its okay).

I hope this helps clear some thing up.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Real simple answer is to add a module and declare your varibles with the Public keyword. Then from each of your forms as you complete your calculations you can assign these/this variable with the result of your calculations. Thus in the next form you should be able to retrieve the valued stored within this/these variables.

However, if you do not want to add a module you can declare a public variable at the top of form1 in the general declarations area. Then you could reference that variable from the other forms via Form1.VariableName = Value or Value = Form1.VariableName as long as you don't unload the form, Hide it until program ends or only unload it after you are done with your calculations.

Good Luck

vb5prgrmr 143 Posting Virtuoso

See my answer to you at vbforums.com

vb5prgrmr 143 Posting Virtuoso

Outlook, Outlook Express, Other? If outlook then search the web for automating outlook vb 6.0.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Type in datediff and press F1 and do the same for Open, SaveSetting, GetSetting, and then search the web for examples on the API's CreateFile and GetFileTime.

Good Luck

vb5prgrmr 143 Posting Virtuoso

For the most simplistic version you could check the creation date of some file you created against the now function, do a date diff based on "d" (day) and if >= 365 display message/shutdown program. However, user could get around this by resetting the date time on the machine. Same goes for using the registry or placing date info in some file.

Now, what may be harder for the user to get around is a count of how many times your program has run as you could hide this count in the registry, in a file, and if you wanted you could attach it to a file on an NTFS drive as in adding a property to a file. Then you could check the count in all three places and see if use has tampered with anyone of the counts. More than likely, a determined user would find the registry setting, file contents, but once they found that file, would they check the properties of that file?

No, real guarenteed way, but many different ways.

Good Luck

vb5prgrmr 143 Posting Virtuoso

name oldfile as newfile

will do the same...

Good Luck

vb5prgrmr 143 Posting Virtuoso
If toclear Like "1" Then

what if there is more than one control without a caption... you should...

if toclear>0 then

Good Luck

vb5prgrmr 143 Posting Virtuoso

lpOperation
Address of a null-terminated string that specifies the operation to perform. The following operation strings are valid: "open" The function opens the file specified by the lpFile parameter. The file can be an executable file or a document file. It can also be a folder.
"print" The function prints the file specified by lpFile. The file should be a document file. If the file is an executable file, the function opens the file, as if "open" had been specified.
"explore" The function explores the folder specified by lpFile.

This parameter can be NULL. In that case, the function opens the file specified by lpFile.

lRet = ShellExecute(vbNull, "", strProgram, "", "", SW_SHOWNORMAL)
lRet = ShellExecute(vbNull, "open", strProgram, "", "", SW_SHOWNORMAL)

Since you are supplying a null string which is different than a null, it would be just easier to add the keyword for the function, "open".

vb5prgrmr 143 Posting Virtuoso

First off, in the future it would be a good idea to also post the err.number and the err.description.

Now, if your err.number is 5 and your description is Invalid proceedure call or arguement then...

The intrinsic shell function built into vb is not used to open data files. It's main purpose is to open exe's. What you need to do is checkout the ShellExecute API.

Good Luck

vb5prgrmr 143 Posting Virtuoso
Dim C As Control
For Each C In Me.Controls
  If C Is TextBox Then
    If Trim(C.Text) = "" Then
      C.SetFocus
      msgbox "message"
      Exit For
  ElseIf C Is ComboBox Then
    If Trim(C.Text) = "" Then
      C.SetFocus
      Exit For
    End If
  End If
Next C

Or...

If C Is TextBox Or C Is ComboBox Then

As you have done

Good Luck

vb5prgrmr 143 Posting Virtuoso

You need to loop through your array...

Dim FoundPass As Boolean, FoundName As Boolean, ForLoopCounter As Integer, UpperBoundOfArray As Integer
UpperBoundOfArray = UBound(ArrNames)
For ForLoopCounter = 0 To UpperBoundOfArray
  If Trim(strUsername) = Trim(ArrNames(ForLoopCounter, 0)) Then
    FoundName = True
    If Trim(strPassWord) = Trim(ArrNames(ForLoopCounter, 1)) Then
      FoundPass = True
      Exit For
    End If
  End If
Next ForLoopCounter
If FoundName = True And FoundPass = True Then
  'validation successful for both
Else
  'something missing
  If FoundName = False Then
    'msgbox...
  ElseIf FoundPass = False Then
    'msgbox...
  End If
End If

Now, while I check for both, you could break the loop up and the following if to put each part in the validate event for each control, or as I have tried to show you could put this under the command button's click event.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Set the computer up so its default printer is pointed to the printer you want.

Good Luck

vb5prgrmr 143 Posting Virtuoso

To help us help you... we need a little more information. Are you using ADO, DAO, or RDO?

vb5prgrmr 143 Posting Virtuoso

Last time i used a stream object was with 2.5 (Microsoft ActiveX Data Objects 2.5).

Dim A As ADODB.Stream
Set A = New ADODB.Stream

'open the adodb filestream and save the file locally so we can check its file size then close the adodb filestream object
A.Type = adTypeBinary
A.Open
A.Write XMLHTTPOBJECT.responseBody
A.SaveToFile App.Path & "\temp.jpg", adSaveCreateOverWrite
A.Close
Set A = Nothing

and if you can't tell I used it with XML 3.0 to save a file to disk from the web.

How you want to use it may require a new thread.

Good Luck

vb5prgrmr 143 Posting Virtuoso

If you are quering a text field then you need to encompass what you are quering against/for with single ticks '

squery = "Select * from tblStation where Station like [B]'[/B]" & txtStation.Text & "[B]'[/B]"

if number then you don't need...

squery = "Select * from tblStation where Station like " & txtStation.Text & ""

Good Luck

vb5prgrmr 143 Posting Virtuoso
sql = "select * from " & Combo2.Text & "'"

You don't need tick on the end.

Good Luck

PinoyDev commented: Very Helpful +1
vb5prgrmr 143 Posting Virtuoso

g_8306 @ vbforums? See replies there

vb5prgrmr 143 Posting Virtuoso

I'm thinking FORM and not forum and the OP is using Access 2k3 and the forms the Access environment provids. It also seems that the form they are using is not bound by query or control but beyond that I am clueless as all others...

vb5prgrmr 143 Posting Virtuoso
Option Explicit

Private Sub Form_Load()
Text1.Text = "This is a test. This is only a test."
End Sub

Private Sub Command1_Click()
Randomize
Dim ForLoopCounter As Integer, TextLength As Integer, TempInt As Integer
TextLength = Len(Text1.Text)
For ForLoopCounter = 1 To TextLength
  If Mid(Text1.Text, ForLoopCounter, 1) <> " " Then
    TempInt = (Rnd * 1) + 1
    If TempInt > 1 Then
      ChangeCase ForLoopCounter, True, TextLength
    Else
      ChangeCase ForLoopCounter, False, TextLength
    End If
  End If
Next ForLoopCounter
End Sub

Private Sub ChangeCase(Position As Integer, UpperCase As Boolean, StringLength As Integer)
If Position = 1 Then
  If UpperCase = True Then
    Text1.Text = UCase(Left(Text1.Text, 1)) & Mid(Text1.Text, 2)
  Else
    Text1.Text = LCase(Left(Text1.Text, 1)) & Mid(Text1.Text, 2)
  End If
ElseIf Position = StringLength Then
  If UpperCase = True Then
    Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) & UCase(Right(Text1.Text, 1))
  Else
    Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) & LCase(Right(Text1.Text, 1))
  End If
Else
  If UpperCase = True Then
    Text1.Text = Left(Text1.Text, (Position - 1)) & UCase(Mid(Text1.Text, Position, 1)) & Mid(Text1.Text, (Position + 1))
  Else
    Text1.Text = Left(Text1.Text, (Position - 1)) & LCase(Mid(Text1.Text, Position, 1)) & Mid(Text1.Text, (Position + 1))
  End If
End If
End Sub
vb5prgrmr 143 Posting Virtuoso

Okay, to print it out by a single field in a specific order, you cannot have another field "requisition_no" ordered first because as you have it now...

req#  ser#
1        5
1        4
1        3
1        2
1        1
2        3
2        2
2        1
...

is the way it is ordered presently. Either switch them around or to print them out use another query.

NOTE: if you order them both DESC (descending) then your recordset will be ordered by most recent first (that is if you have an incrementing req# and ser#).

Good Luck

vb5prgrmr 143 Posting Virtuoso
"ORDER BY MaterialRequisitionOrder.serialno DESC;"
vb5prgrmr 143 Posting Virtuoso

I am guessing you are using access as your database, Goto the design of the table and check each field to see if down at the bottom the required is set to yes.

vb5prgrmr 143 Posting Virtuoso

inserting into a table should not be a problem as long as you add values for each field that has the required arguement set to yes. However, you may be able to get around the need for this by specifying a default value.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Are you using .NET? if so you are in wrong forum...
but this works for me

Option Explicit

Private Sub Form_Load()
Dim S As String
S = "string1" & vbNewLine & "string2" & vbNewLine & "string3" & vbNewLine & "string4" & vbNewLine
S = S & "string5" & vbNewLine & "string6" & vbNewLine & "string7" & vbNewLine & "string8"
Text1.Text = S
End Sub

Private Sub Command1_Click()
Text1.Text = StrConv(Text1.Text, vbProperCase)
End Sub
vb5prgrmr 143 Posting Virtuoso

How about one line...

Option Explicit

Private Sub Form_Load()
Dim S As String
S = "string1 string2 string3 string4 string5 string6 string7"

S = StrConv(S, vbProperCase)
Debug.Print S

End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

Insert into tablename (field1, field2) values (value1, value2)

Okay, the above is the basic psudo code design of your insert statement. Now where it says field1 that represents your First Name field and you are getting the error that says it cannot find the first name field. So, one of the easiest ways to figure this out is to open the table in design view, find the first name field, highlight it, copy the field name, and then paste it into your code.

The reason for these steps is I am betting that the first name field might be named differently like first_name or as I sometimes like to do FName. So make sure that you have the correct spelling for your table name and field names. Then check to make sure they are of the correct data types.

Good Luck

vb5prgrmr 143 Posting Virtuoso

HI v5prgrmr Dim mysql As String = "insert into Customer_tbl values('First Name','Last Name') values ('John','Unknown');"

Ahh... My bust. Dim mysql As String = "insert into Customer_tbl ('First Name','Last Name') values ('John','Unknown');" Remove that first values

vb5prgrmr 143 Posting Virtuoso

update Details set NAME='" & txtName.Text & "' and DT_OF_BTH=#" & txtDOB.Text & "# and DT_OF_JOING=#" & txtDOJ.Text & "# and SALARY_ACC=" & txtAccountNo.Text & " and REMBSMNT_ACC=" & txtRmbr.Text & " and PHONE_NO=" & txtPhno.Text & " where PS_No=" & Trim(txtPSNo.Text)

I think that should do it

vb5prgrmr 143 Posting Virtuoso

Use the Format function

txtreceitno = Format(rs.fields("orno") + 1, "00000")

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, then all you need is the last line of the readfile...

ReadFileReturnStringArray = Split(StringContents, vbNewLine)
vb5prgrmr 143 Posting Virtuoso

comment Unload Me in your code and i hope the rest wills tart working. use Me.Hide instead of unload Me.

I take it you did not read my post too well...

vb5prgrmr 143 Posting Virtuoso

Access does not like it when you pass up a string for a number field and that is what you are doing when you wrap your numbers with quotes.

vb5prgrmr 143 Posting Virtuoso

Couple of possibilities

Lets start with the date. Are you sure it is a properly formatted date?
What DBMS (Access, SQL, dBase)?
Each handle dates just a little bit differently. If you are using Access then go to the query analyzer, build your insert string there and see what characters it uses to wrap around the date field. Take that knowledge and apply it to your update string.

Now, onto salary. You are wrapping a number with single ticks ' so you are telling your database to update a number with a text string and it looks like you are doing the same for the other number fields in your statement.

Other worries:
I don't see any validation code, meaning are you sure the information that the use is entering is valid. i.e. the user is not trying to update the salary field with a string like "'Fifty thousand dollars and no cents'"

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, right of the bat I can see a potential problem with your timer control and its sub procedure. Not knowing, as I only read the first few lines, what your timer interval is set at I can guess that it may be way too low causing a problem called reentrancy, which means that the first time the timer is called, if the code inside the timer does not complete before the timer is triggered again, then you have the same code starting to execute again. The second thing that I see wrong with the code inside the timer is that you try to unload the form but you do not stop the timer by setting its enable property to false or by setting its interval property to zero. Now you can do this in the form unload event but I don't see that code posted.

So here is what seems to be happening with your code. The form displays, the timer triggers, and lickity split the progress bar reads 100% and you unload the form. Problem is, the timer activates again thus reloading the form and starting the process all over again in an endless loop.

So how to fix this...

There are a couple of ways and what follows is just one.

First you could use a variable declared at form level...

Option Explicit

Dim TimerCounter As Integer

Then in your form load event you setup your timer and progress bar

Private …
vb5prgrmr 143 Posting Virtuoso

Why loop on input when you can read whole file in in one step?

Public Function ReadFileReturnStringArray(PathFileName As String) As String()

Dim FileNumb As Integer,  FileContents As String

'get a free file handle
FileNumb = FreeFile

'open file
Open PathFileName For Binary As #FileNumb

'retrieve its contents
FileContents = Input(FileLen(PathFileName), #FileNumb)

'close file to reclaim resources asap
Close #FileNumb

ReadFileReturnStringArray = Split(FileContents, vbNewLine)

End Function

Then from calling proc

Public Sub CallingSub()

Dim MyArray() As String, UpperLimitOfArray As Integer, ForLoopCounter As Integer
Dim MySearchString As String, FoundSearchStringPosition As Integer

MyArray = ReadFileReturnStringArray("C:\YourPath\YourFile.Extension")

UpperLimitOfArray = Ubound(MyArray)

MySearchString = "Test"

For ForLoopCounter = 0 To UpperLimitOfArray
  
  FoundSearchStringPosition = InStr(1, MyArray(ForLoopCounter), MySearchString)
  If FoundSearchStringPosition > 0 Then
    
    Call SomeSubToProcessString(Mid(MyArray(ForLoopCounter), FoundSearchStringPosition))
    
  End If
  
Next ForLoopCounter

End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

I been searching for days for a sulotion but can't seem to find one.
The coed that I have does not give me an error but it does not save anything on the table either '
Can someone help me find what I'm missing?
this is my coed

Dim mycon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\DEsign.accdb"
        Dim customer As String = "select * from Customer_tbl"
        Dim Notes As String = "select * from Notes_tbl"
        Dim con As New OleDb.OleDbConnection(mycon)
        Dim comCustomer As New OleDb.OleDbCommand(customer, con)
        Dim comdNotes As New OleDb.OleDbCommand(Notes, con)
        Dim Custsql As String = "first name,Last Name"
        Dim Sql As String = "insert into Customer_tbl [b](Custsql )[/b]values '" & txtFirstName.Text & "','" & txtLastName.Text & "')"
        comCustomer = New OleDb.OleDbCommand(Sql, con)
        
        con.Open()
        comCustomer.ExecuteNonQuery()
       comCustomer.Dispose()
        con.Close()

Thank you
Viper

Should be...

Insert Into Table Values (Field_1_Name, Field_2_Name) Values (Field_1_Value, Field_2_Value)

Good Luck

vb5prgrmr 143 Posting Virtuoso

Only a guess, but it looks like you may be comparing an integer with a string. Set a breakpoint on or just before line in question, then user cursor to hover over each value to be evaluated, or use debug window, and check to see if itemcode(i) actually has a value and if Grd.TextMatrix(CLng(row), 1) is returning a string. i.e. "1"

Good Luck

vb5prgrmr 143 Posting Virtuoso

Dear Deba what your answer!

dear vb5prgrmr, please clear and details.

Quite simple. Start a new project, add a button, add the code, run program, click button.

Good Luck

vb5prgrmr 143 Posting Virtuoso

ok but wait, wat's the diff? o i no, it's that vb can't use classes rite? not OOP? ic

ps. look at the filename of the attachment, of course it's a joke :)

Man oh man where do I start?

First off, its the syntax that is different between C++ and VB. For example in C it is the parens() that define or contain an if or class where as in VB its a whole differt declaration...

Private MySub()
If ThisIsTrue = True Then
End If
End Sub

Public MyFunction(Arguement1 As String, Arguement2 As Integer) As Byte()
End Function

Now, VB can use classes especially since to add a class it is as simple as a couple of mouse clicks but "Classic VB" or versions 4/5/6 do not support true inheritance and VB is or can be OOP if you know what you are doing and you know what OOP is.

As for your joke, your file has been renamed to http://www.daniweb.com/forums/attachment.php?attachmentid=9400&d=1236124107 so some if not all of us probably don't get it.

vb5prgrmr 143 Posting Virtuoso

how am I going to do that?

For each object you open (cn.open/rs.open) you need to close (rs.close/cn.close). So if you have a global/public connection and any global/public recordsets open, you close, copy, and then reopen if you want to continue on with your program.

Good Luck

vb5prgrmr 143 Posting Virtuoso

If you have the database open via your code or through the access application then you will recieve this error. You need to close all connections to the database prior to trying to copy it.

Good Luck

vb5prgrmr 143 Posting Virtuoso

then you need to push the power button on your computer.

No that would be how my computer on not how to open the box to my computer :D

vb5prgrmr 143 Posting Virtuoso
Shell "rundll32.exe shell32.dll,Control_RunDLL"