DLL Function Not Working
Does anyone know why the function below will work when it is included in my project but if I put it in a DLL and I call the function it gives me a an error: "Object variable or with block variable not set." I am pretty sure it gives me the error for trying to set the ConnectionString, but why would it be an error? I set the Variable to new and I also include ADO in both the DLL and my project. I tried setting the connection to a new connection on a separate line and it still gives me an error.
VB Code: Public Function AccountCode(ByVal sCust As String, _ ByVal sClass As String, _ ByVal sUsedFlag As String, _ ByVal sAccountCode As String, _ ByVal sConnectString As String) As String Dim sSQL As String Dim rsAccountCode As New ADODB.Recordset Dim Connection As New ADODB.Connection Dim sModifiedCode As String On Error GoTo ErrHandler Connection.ConnectionString = sConnectString Connection.Open rsAccountCode.ActiveConnection = Connection Select Case sCust Case "JL" sSQL = "SELECT * FROM JLAccountCodes WHERE [Account Code] = '" & sAccountCode _ & "' AND [Class] = '" & sClass & "'" rsAccountCode.LockType = adLockReadOnly rsAccountCode.CursorType = adOpenStatic rsAccountCode.Source = sSQL rsAccountCode.Open End Select AccountCode = rsAccountCode("Modified Account Code") rsAccountCode.Close Set rsAccountCode = Nothing Connection.Close Set Connection = Nothing ErrHandler: If Err.Number <> 0 Then MsgBox Err.Description, vbOKOnly, Err.Number & " AccountCodeDLL" Resume Next End IfEnd Function
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Why Isn't This Function Working?
Ok So I wrote this function to Display a timer counting down...
* Not the Timer Control A Timer Function
Its not throwing any erros (Hopefully I'd be able to use a function I wrote )
And When I step through it it displays the correct info when i put my mouse over it.
When I use it for a mulipaneled statusbar it works!
Code:
Private Sub Command1_Click()
WaitFor 5000, StatusBar7
End Sub
Public Function WaitFor(ByVal intSeconds As Integer, _
ByRef cntControl As StatusBar, _
Optional ByVal intPanel As Integer)
For intSeconds = intSeconds To 0 Step -1000
If intPanel <> 0 Then
cntControl.Panels(intPanel).Text = "Timer: " & intSeconds
Else
cntControl.SimpleText = "Timer: " & CStr(intSeconds) 'Not Updating Statusbar to display info!
End If
SecondsToWait 1000
Next
End Function
Function Not Working Too Well
Hello, here is my code
Form Load()
msgbox isbusy
End Function
Public Function isbusy() As Boolean
Dim cnt As Integer
For cnt = 0 To 255
If GetAsyncKeyState(cnt) <> 0 Then
isbusy = True
MsgBox Chr$(cnt)
Else
isbusy = False
End If
Next cnt
End Function
As you can see, this function checks to see if a key is being pressed. While I am pressing a key and run this program, the function outputs the key, but the call prints out "False" when it should be "True." When i am not pressing a key, it prints "False" like it is expected to. Any ideas?
Mid Function Not Working??
Hi,
I have just reinstalled windows after a hdd format.
I have my project all running again except for one little glitch.
I have the lines
Private Sub Combofemales_Change()
TextBox(6) = Mid(Combofemales, InStr(Combofemales, "[") + 1, InStr(Combofemales, "]") - InStr(Combofemales, "[") - 1)
End Sub
Private Sub Combomales_Change()
TextBox(5) = Mid(Combomales, InStr(Combomales, "[") + 1, InStr(Combomales, "]") - InStr(Combomales, "[") - 1)
End Sub
The programe stops on a full compile at the first "TextBox(6) = Mid" and highlights the string mid in BLUEand tells me
"Cannot find project or library"
Can anyone suggest what ive missed.
Many thanks
L
Mid Function Not Working!!
Hello,
I have this code given to me by I think it was MartinLiss, or somebody, it worked the first day they gave it to me, now it does not work? Anybody know why??
VB Code:
For i = 1 To StringLenIf Mid(phrase, i, 1) = letter Then MsgBox "There is an " & letter & "!" Exit ForEnd If
Mid$ Function Not Working
Can someone tell me what is wrong with this code. When I try to run it there is a run time error 5 "invalid call, function"...
VB Code:
strB = "----------------------------------------" txtAmajSpc.Text = intAmajSpc lngPos = Val(intAmajSpc) lngPos = lngPos strFretNumb = "2" strB = Left$(strB, lngPos - 1) & strFretNumb & Mid$(strB, lngPos + 1)
txtAmajSpc is a textbox on form where user inputs a number
Anyone know what's wrong?!
Str Function Not Working ???
I am using one variant type argument in a function. passing numeric value to it. and trying to add it in a string. e.g. eno is the argument and value of it is 111 now I have written
"select * from emp where empno = " + eno
but type mismatch error occurs. I tried for str(eno) but all sudden str is not working. what can be the reason and solution ???
Function Not Working?
Hi
This is hard for me to explain so bear with me
I am working on a calendar. I am working on a mousemove event for cmdday()
this will propogate special day information to txtDayEvent ie holidays.
Oh well enough explination the is the code that doesn't seem to work any suggestions?
Code:Private Sub ProcessButtonMouseMovecmd(index As Integer)
Dim i%
Dim mm%
mm = Month(lblmonth.Caption)
Select Case cmdDay(index) 'refering to the arrays index
Case 1
If mm = 1 Then
txtDayTitle.Text = "Martian Luther King Day!!"
End If
end select
and the button code
Code:Private Sub cmdDay_MouseMove(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
ProcessButtonMouseMovecmd cmdDay(index).index
End Sub
Thanks Natdrip
"I'm not a Nerd, I just prefer Dating invisible women"
Format Function Not Working
I have developed a simple program which is working fine on my pc but when i install it on another pc the format function does not seem to be working. An input box comes up 'Enter parameter value' Format
I have checked the file msvbvm60.dll is in the system32 folder and registered it manually by regsvr32 "c:winntsystem32msvbvm60.dll" and it said it was successful but format function still not working.
this is my code
If Me.txtDateTo = "" Then
sCriteria = "[RptDate] = #" & Format(Me.txtDateFrom, "mm/dd/yyyy") & "# and [Dept]='" & Me.Combo1 & "'"
Else
sCriteria = "[RptDate] between #" & Format(Me.txtDateFrom, "mm/dd/yyyy") & "# and #" & Format(Me.txtDateTo, "mm/dd/yyyy") & "# and [Dept]='" & Me.Combo1 & "'"
End If
what else do i need to do????
Custom Function Not Working
I have a custom function written in VB--a fairly simple one--and it's returning #VALUE!. I've worked out the formula by hand, and it should work. I'm not very familiar with VB code and excel--have I done something wrong? (Attached is the file). Thanks!
Query Function Not Working
I have this code in a VB project, (NOT VBA)
Code:
With agent
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source=c:alarmFilmRentals2.mdb"
.Open
End With
orgchart.Open "SELECT Orgchart.Name FROM orgchart WHERE ((FindString([Name], 'Yach')=True));", agent, adOpenStatic, adLockOptimistic
Debug.Print orgchart.RecordCount
it gives me error, "Undefined Function in 'FindString' in expression" even though i have the function well defined in both the database and the VB project (in a module)
help?
Triming Function Not Working
this function is supposed to take any html and remove all of the tags
for ex
Code:
htmlpage = trimAlltags(htmlpage, "<", ">")
htmlpage= "<h1><span pageTemplate_Default_Element1_lblHeading" Copy_Titles_Large_Bold">Prices</span></h1>"
or try this
htmlpage="<span pageTemplate_Default_Element1_lblCopyShort" Copy_Sub">Don't pay too much! </span>"
it works but does not trim all the tags in the source
any ideas?
i think i might have screwed it up with the
If mStartPos = 0 Then GoTo Done
but if i remove that then
mEndPos = InStr(mStartPos, LCase(SourceTxt), LCase(endTag))
gives me a runtime error 5
Code:
Function trimAlltags(SourceTxt As String, beginTag As String, endTag As String) As String
Dim mString As String
Dim mStartPos As Long, mEndPos As Long
mStartPos = InStr(1, LCase(SourceTxt), LCase(beginTag))
'# of the begin
mEndPos = InStr(mStartPos, LCase(SourceTxt), LCase(endTag))
'# of the end
'find the 1st end of the string
'look at the things in brackets and delete them loop
Do While mStartPos <> 0 And mEndPos <> 0 And mEndPos > mStartPos
mString = Mid(SourceTxt, mStartPos, ((mEndPos - mStartPos)) + Len(endTag))
MsgBox "trimming this= " & mString & " from " & SourceTxt
SourceTxt = Replace(SourceTxt, mString, "")
MsgBox "sourcetxt became " & SourceTxt
mStartPos = InStr(mEndPos, LCase(SourceTxt), LCase(beginTag))
If mStartPos = 0 Then GoTo Done
mEndPos = InStr(mStartPos, LCase(SourceTxt), LCase(endTag))
'mStartPos = InStr(1, SourceTxt, beginTag)
'mEndPos = InStr(mStartPos, SourceTxt, endTag)
Loop
Done:
trimAlltags = SourceTxt
End Function
Left() Function Not Working
Hi!
I have written a program that WAS working just fine but for some reason now bombs when I try to complie it.
Here is a section of my code...
Code:
Do While Not openFile.AtEndOfStream 'Do until the end of the file is reached
strLine = openFile.ReadLine
If InStr(1, strLine, "Part Name : ", vbTextCompare) Then
sTemp = Replace(strLine, "Part Name : ", "")
pos = InStr(1, sTemp, ":", vbTextCompare)
sDescription = Left(sTemp, pos - 1)
sTemp = Replace(sTemp, sDescription & ":", "")
pos = InStr(1, sTemp, ";", vbTextCompare)
sPN = Left(sTemp, pos - 1)
sTemp = Replace(sTemp, sPN & ";", "")
sVersion = sTemp
'Read the next line
strLine = openFile.ReadLine
If InStr(1, strLine, "Project/Catalog: ", vbTextCompare) Then
sTemp = Replace(strLine, "Project/Catalog: ", "")
pos = InStr(1, sTemp, ":", vbTextCompare)
sProject = Trim(Left(sTemp, pos - 1))
sTemp = Replace(sTemp, sProject & " :", "")
sLibrary = Trim(sTemp)
End If
If sDescription = "" Then
sDescription = "*"
End If
If sPN = "" Then
sPN = "*"
End If
prt.Add sDescription, sPN, "", sVersion, "", "", sProject, sLibrary
End If
Loop
Set PartList = prt.Parts
Exit Function
The problem is that the Left function is not recognized. If I comment the Left function line out the program will compile. All of the other similar functions like mid, right, and instr work fine. It appears to be a missing reference of some kind but Im not sure which one it is.
Any ideas would be great!
Thanks!
Private Function Not Working
I got this function which when the form starts up, it recreates lines to spit up a canvas into squares. Then I reuse it to clear the lines and redraw them when there canvas is resize, but it keeps on getting an error saying object already loaded
Thanks in advance
Kaluriel
Code:
Private Function BliteLines()
If Line1.Count > 1 Then
i = 1
Do While i <= Line1.Count
Unload Line1(i)
i = i + 1
Loop
End If
Line1(0).X1 = 32
Line1(0).X1 = 32
Line1(0).Y1 = 0
Line1(0).Y2 = Picture1.ScaleWidth
a = (Picture1.ScaleHeight 32)
b = (Picture1.ScaleWidth 32)
c = Line1.Count
Do While c <= a
Load Line1(Line1.Count)
Line1(c).X1 = 0
Line1(c).X2 = Picture1.ScaleWidth
Line1(c).Y1 = (c * 32)
Line1(c).Y2 = (c * 32)
Line1(c).Visible = True
c = c + 1
Loop
d = 1
Do While d <= b
Load Line1(Line1.Count)
Line1(c).X1 = (d * 32)
Line1(c).X2 = (d * 32)
Line1(c).Y1 = 0
Line1(c).Y2 = Picture1.ScaleHeight
Line1(c).Visible = True
d = d + 1
c = c + 1
Loop
End Function
Edit: JDT switched tags
Sleep Function Not Working Too Well
Hello, sleep is causing my system to freeze under the following circumstances
whereas sleep is defined as coming from the kernel32 dll
for i = 0 to 19
sleep 1000
msgbox i & " seconds have passed"
if i = 19 then
msgbox "time is up"
end if
next i
please keep in mind that i do not want to use the timer control for pausing the 1 second - i want to use sleep. any ideas? please respond to my email
jstic04@cp.centennialcollege.ca
Format() Function Not Working At All
I've recently returned to VB6 and am having an issue with the Format() function. I wrote a program years ago and it worked correctly then. When I try to run it now it gives me that compile error "can't find library" at all the Format functions.
An example of how I'm using it is like so:
string = "C: " + Format(getHDUsed, "###,.00") + " GB"
I'm thinking that I'm missing some kind of add-in or library but I don't know which is associated with the Format function. Nor do I even remember how to install add-ins or libraries. If anyone could help me with this, it would be much appreciated.
Function Not Working When Using Other Computer
as the title states,
i'm creating a database system. everything worked fine when using my computer but, when tested with other computers, deleting records doesn't work..
anyone know what's the cause of this?
Sendkey Function Seems To Not Be Working
VB Code:
Option Explicit Private Sub command1_Click()Timer1.Enabled = TrueEnd Sub Private Sub Timer1_Timer()Dim i as integerFor i = 0 To txttimes.TextSendKeys tmrtext.Text & Chr$(13)Next itmrTime.Enabled = FalseLabel1.Caption = "Times Spammed: " & i = i + 1End Sub
Someone tell me what wrongs please. And btw it ain't erroring?
Calling This Function - Not Working!!
im trying something like
wb.Document.Forms(0).Item(1).Value = RandomString(Me)
and in a module i have this..
VB Code:
Public Function RandomString(param As String) As String RandomString = "Hello" param.Text1.Text = "hello!"End Function
how would i make this work?
IsNull Function Not Working
Just curious...
Has anyone ever had any problems with the IsNull function not working properly?
I am almost finished coding a rather large application and one thing I noticed is that the first time you write it, it doesn't always work.
For example, if I wrote a statement like this (as an example)...
VB Code:
If IsNull (.Fields!NAME) = True Then BeepEnd If
and the field "NAME" was in fact null, it would skip right over the "beep" line the first 2 or 3 times the program ran. Then, it work work everytime after that.
I guess I'm saying it doesn't always work as it should for me....howcome?
Weekday Function Not Working
Hello, the following code below works fine if I use it in a Sub Main procedure, but for some reason the exact same procedure will not work in a form load or in a function I. I am getting a type mismatch error in the form load and the function. Anyone know why this is happening? I am using Access 97.
Thanks
James
'Works
Sub Main()
If Weekday(Date) = vbTuesday Then
MsgBox "Yes"
Else
MsgBox "No"
End If
End Sub
'Does not work
Private Sub Form_Load()
If Weekday(Date) = vbTuesday Then
MsgBox "Yes"
Else
MsgBox "No"
End If
End Sub
Unzip Function Not Working
Private WithEvents m_cUnzip As cUnzip
m_cUnzip.ZipFile = sFIle
' Set the base folder to unzip to:
m_cUnzip.UnzipFolder = sFolder
' Unzip the file!
m_cUnzip.Unzip
i downloaded the cUnzip.cls and mUnzip.bas module and class file from http://www.vbaccelerator.com/codelib/zip/unzip.htm but it doesn't seem to call unzip to actually perform the unzip. I don't know if this helps much with little info..but maybe someone know the typical issues that causes this..
Working With Instr Function. Pls Help
Please look at the code below and I will tell you what my problem is.
Dim strDesc As String 'a variable for the description
strDesc = InputBox("Please enter a description.")
'Now checking is the description typed in inputbox is having a single qoute(') or not.
If InStr(1, strDesc, "'", vbTextCompare) <> 0 Then
strDesc = Replace(strDesc, "'", "'||CHR(39)||'", 1, , vbTextCompare)
End If
'Now inserting the description values from the input box into the table
con1.Execute "insert into movie values("'" & strDesc & "')"
My problem here is the user can type anything in the Description input box. And whenever the user types a word having a single qoute(') then the insert statement doesn't work. Insert statement stops when it encounters that single qoute(') in the description.
Therefore I've used a Instr function to take care of this. But this doesn't seem to work I don't know how to work with Instr function.
Please help me to solve this problem
Thanks
Replace Function Not Working
Hello, I am having a lot of problems with the Replace() command. I looked it up and found this:
Replace(expression, find, replacewith[, start[, count[, compare]]])
So I typed this:
Replace prepareString, "'", "''"
And I get an error:
Type Mismatch: Array user defined type expected.
It highlights the prepareString. Can someone Tell me what I am doign wrong? Thanks a lot.
~evlich
Working With HEX Strings And Xor Function
I have beating my head against the wall with hex numbers in vb.
Any help would be greatly appreciated.
Basically I have a hex string (actual data varies), that I am trying to generate a simple checksum using the Xor Function.
It runs like this:
"00C91FEE1A00445B" is a test string that represents 8 bytes of hex data. I want to Xor bytes 1&2 then bytes 3&4 then bytes 5&6 then bytes bytes 7&8 to produce a 4 byte hex result. The input and output must be hex string data.
00C91FEE1A00445B would produce 00F11A1F using this formula.
I have tried several times... but I have had no luck.
What would be a good way to approach this senario???
Thanks
Print Function Not Working
is there any possible way, for some one that is really good at programming, that I would be able to email them my project, and see if you would be able to get the print function to work, please tell me if anyone would be willing to do this for me
String Function Not Working?
I can start a new VB project with a button and a label. The only code that runs when you hit the button loads the label with an uppercase word, ie. lblText.Text = Ucase("test"). This works fine.
But, when I bring in a project (that has worked for months) that does the same thing - I get an error that says Compile error - Can't find library. VB highlights the word Ucase. If I right click on Ucase and choose Definition - VB says it's not recognized.
Any ideas?
I did reload the PC from scratch before this started happening.
Left() Function Not Working?!
umm this sounds reallly stupid but the left() function isn't working for me anymore?...
umm here's my call:
Left(varstringtotrim, varlengthtotrim)
and it's returning a runtime error 5: invalid procedure call or arguement......
when im working in vb, and start typing Left( it should come up with the proper syntax thing.... it does this for the Right() function, but not the left function?!
what the heck is happening? it does this in ANY project..... i am dumbfounded!!!
HELP!!
Inverting The RGB Function Isn't Working
Hi all,
I want to get the red/green/blue values from a long integer representing a screen colour. This is my code:
'assume k is a combination of red + green + blue, for example:
k = &HABCDEF'...just any value for testing
'Now set to zero the non-significant bits
'and right shift the result as many places as needed
red = ((k And &HFF0000) 256) 256
green = (k And &HFF00) 256
blue = k And &HFF
'convert to hex so it's easier to debug
kk = Hex(k)
k1 = Hex(red)
k2 = Hex(green)
k3 = Hex(blue)
The surprise is red and blue come out right, but green does not! What's wrong???
Timer Function Not Working
Hello everyone.
I'm having trouble getting a timer to work properly in VB6. Basically I want the user to input a time in minutes and seconds into a text box that will then wait that specified amount of time until a sound, or as of now a beep, plays. Pressing a begin button would then start the timer up which has already been set to have an interval of 60000 milliseconds - or one minute. I searched the forum and came up with a few pieces of advice - but trying to implement them usually ended in the program not working correctly.
The main problem seems to be that the timer will not recognize that it needs to wait more then one minute until beeping. I have another text box that displays the amount of time left in minutes, and when the timer finishes it's sixty second run, the sound plays prematurely and the countdown timer text box displays '0'.
Here's part of my current code.
Code:
Public iMinutes As Integer
Private Sub btn_begin_Click()
'Variables
Dim numofmin As Integer
Dim numofsec As Integer
Dim reptimer As Integer
Dim sounag As Integer
Dim genbeep As Integer
Dim chosoun As Integer
Dim secconver As Long
Dim minconver As Long
Dim totaltime As Double
'Time Variables
Dim begintime As Date
Dim endtime As Date
Dim elapsedtime As Long
'Input
numofmin = Val(txt_numberofminutes.Text)
numofsec = Val(txt_numberofseconds.Text)
reptimer = Val(chk_repeattimer)
sounag = Val(txt_soundagain)
genbeep = Val(chk_genericbeepsound)
chosoun = Val(chk_choosesound)
oneminute = 0
'Conversion
secconver = (numofsec / 60)
minconver = numofmin
totaltime = secconver + minconver
'Countdown
tim_timercount.Enabled = True
txt_countdowntimer.Text = totaltime
End Sub
Private Sub tim_timercount_Timer()
tim_timercount.Interval = 60000
ioneminute = ioneminute + 1
If oneminute = totaltime And chk_genericbeepsound = 1 Then
Beep
End If
txt_countdowntimer.Text = totaltime - oneminute
End Sub
I'm new to programming so any help would be appreciated.
DIR Function Not Working As Expected
Hi, I seem to be having a problem with the DIR function. I have written code similar to below:
CODE
strFile = DIR("C:*.csv",vbnormal)
intCounter = 0
Do while strfile <> ""
{Do Stuff including call other functions}
If intCounter = 0 Then
Else
strFile = Dir
End If
intCounter = intCounter + 1
Loop
Excel Function Not Working
Hi
Can any One Help me?
I have exports some record to excel. I have formatted excel cells as text first setting numerformating property of cell as "@" so that leading zero exists then reformatted to as general. But I face problems while working with the sheet. Excel function like sum, max is not working.
Please help. it is urgent.
kashem
Format Function Not Working
Hello Gurus..........
I have this project made in VB6.0, Access 2003 backend and CR 8.0. during the course of development of this project, I wa forced to format my PC and reload XP SP2 and all other softwares. Thereafter, when I tried to run the project , I am getting an error message " Item or library not found" and it is pointing to format function in line
ToDate = format(Now,"dd-mmm-yy").
I tried to correct this by incorporating FormatDateTimeConstants function instead of Format alone. However, in places where I had to use format [ like in format(MonthName(month(Now)))], I get the same error.
I am not getting any error if I open a new project and use the same function.
Can any one please help me?
GeoNav
Recursive Function In Formula Not Working?
I am trying to use a recursive function to return the number of levels for a specific parent but once I put the function in an equation it doesn't work. I receive a "ByRef Argument type mismatch error" for Level(Temp) which is fine when on a stand alone line.
Code:
Function Level(Parent As String) As Integer
Dim Temp As Variant
Temp = DLookup("[Component]", "TestData", "[ItemNo] = '" & Parent & "'")
If IsNull(Temp) Then
MsgBox ("Found NULL")
Level = 1
Debug.Print "ItemNo Component", "Level"
Debug.Print Parent; " "; Temp; " "; Level; Chr$(13)
'Done
Else
MsgBox ("Found ItemNo")
Debug.Print "ItemNo Component", "Level"
Debug.Print Parent; " "; Temp; " "; Level; Chr$(13)
'**** This Works Fine
Level (Temp)
'**** This Doesn't Work, Why?
'Level = Level + Level(Temp)
End If
End Function
Any help would be appreciated. Thanks.
Stupid Month() Function Not Working??
I'm woking in Access 2000. I'm simply trying to get the month of a certain date. Naturally I'd want to use Month(). Unfortunately Microsoft has decided that I should not use this and has subsequently made it mysteriously absent from my usable functions.
Strangely enough I can use the Year() function just fine in the same form.
Does anyone know why this is happening? Thanks very much!
Date Function Has Stopped Working
I have the following line of code that has just stopped working all of a sudden. Can anybody tell me why??
DTPicker1 = CDate(Date)
It doesnt like the Date bit. Do I need to enable a componenet again or something??
InStr Function Not Working On Certain PCs (eMachines)
I know this sounds weird but my program seems to work fine on most computers except eMachines, I know they **** but do they to the point they dont support basic functions?
This line is constantly evaluating to false unless frmMain.txtContaining.Text contains nothing, even if it is in strURL:
If InStr(1, LCase(strURL), LCase(frmMain.txtContaining.Text)) > 0 Then
Thanks
'Date' Function Not Working On Finnish PC's?
I recently built a quick tool using VBA for Excel (VBA version 6). I used the following line to store the current month from the system clock
mymonth = month(Date)
this worked fine for me and my friends in the UK. When I sent this to some Finnish guys they got compile error, debugger highlighted Date and message was 'Cannot find project or library'.
The Finns had VBA 6 and same excel version 9.0.4402 SR1
I tried to re-create the error by removing as many as possible of the available references from the tools menu but it still worked fine for me.
If anyone able to tell me why or give a clue where to look next I'd be very very grateful,
Thanks,
Ian
Removeline Function Not Working Properly
VB Code:
Public Function RemoveLine(sFile As String, sLine As String, sSep As String)Dim sText$, iPos%, iPos2% Open sFile For Input As #1 sText = Input(LOF(1), #1) iPos = InStr(1, sText, sLine) If iPos > 0 Then iPos2 = InStr(iPos + Len(sLine), sText, sSep) If iPos2 > 0 Then sText = Left(sText, iPos - 1) & Mid(sText, iPos2 + Len(sSep)) Else sText = Left(sText, iPos - 1) & Mid(sText, iPos + Len(sLine) + Len(sSep) + 1) End If End If Close #1 Open sFile For Output As #1 Print #1, sText; Close #1End Function
RemoveLine "C:emails.txt", "test@msn.com=password", vbNewLine
it removes it but leaves in the 'd' (sometimes it leaves more..)
so doesnt fully remove it
emails.txt entries are like
email@msn.com=454
email4@msn.com=4543
Dir Function On Network Path Not Working?
I want to determine if a network path exists and if it doesn't I want to create the path. For some reason the Dir function returns "" even if I give it a valid path.
example:
There is a path on my network called - \wawa0csiojamie
if I do ? dir("\wawa0csiojamie",vbdirectory)
or anything else... I get ""
Help?
Format Function Not Working For Date
Hi all,
I'm havind a date in 01.03.2006 format. while
inserting it into database I need that date in the format
Monday,March 01,2006 . I have used the format function. But it
is not working for me. I'm getting my original date itself. Can
any one tell me what to do.
Thanks
Rachel
Copy Paste Function Not Working
he I have been bulding a program in VB 6.0 and need something that can copy from a rich text box and paste into a word document. Earlier I had a code that would work, however after changing the limit of my text box from 255 characters to unlimited it no longer works. any ideas?????
Code:
Private Sub ATA_Click()
With Adodc2
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "ATA.mdb;Persist Security Info=False"
.RecordSource = "select * from Table1"
End With
Dim ATAList As Recordset
Dim ItemID As String
Set ATAList = Adodc2.Recordset
ATAList.MoveFirst
ItemID = Str(ATA.ItemData(ATA.ListIndex))
ATAList.Find "ID =" & ItemID
'Clears Textbox if there is anything in it before it fills again
ClearText
ClearSubATA
'Teh following checks to see if the Description Exists in the
'previous box, if it doesn't then the SubATA box is filled up
'If it does then the Description is loaded into the Textbox
Dim Check As String
Check = ATAList!YN
If Check = 0 Then
BuildSubATA (ItemID)
Else
WrdText2.TextRTF = ATAList!Description
End If
End Sub
Sub ClearText()
If WrdText2 <> "" Then
WrdText2.TextRTF = ""
End If
End Sub
Sub BuildSubATA(TheItemID As String)
With Adodc3
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "ATA.mdb;Persist Security Info=False"
.RecordSource = "select * from " & TheItemID
End With
Set SubATA.DataSource = Adodc3
Dim ATASubList As Recordset
Set ATASubList = Adodc3.Recordset
ATASubList.MoveFirst
Do While Not ATASubList.EOF
SubATA.AddItem ATASubList!AtaSubNumber
SubATA.ItemData(SubATA.NewIndex) = ATASubList!Id
ATASubList.MoveNext
Loop
End Sub
Sub ClearSubATA()
Dim Craping As Boolean
Dim All As Variant
If SubATA.ListCount <> 0 Then
Craping = True
End If
Do While Craping
SubATA.RemoveItem All
If SubATA.ListCount = 0 Then
Craping = False
End If
Loop
End Sub
Private Sub Form_Load()
' set up the database connectivity for the ADO data control
With Adodc2
' Connect to the Access Database using MS Jet SQL drivers
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "ATA.mdb;Persist Security Info=False"
' tell the data control what and how
' to pull out of the database.
.RecordSource = "select * from Table1 order by AtaNumber"
End With
'Set the listbox ATA datasource to Adodc2
Set ATA.DataSource = Adodc2
'Define the recordset and tell it what set to access
Dim ATAList As Recordset
Set ATAList = Adodc2.Recordset
If Not ATAList.EOF Then ATAList.MoveFirst
Do While Not ATAList.EOF
ATA.AddItem ATAList!AtaNumber
ATA.ItemData(ATA.NewIndex) = ATAList!Id
ATAList.MoveNext
Loop
End Sub
Private Sub Insert_Click()
CommandButton1_Click
Dim xWord As Object
WrdText2.SelStart = 0
WrdText2.SelLength = WrdText.TextLength
WrdText2.Copy
Set xWord = GetObject(, "word.application")
xWord.Selection.Paste
xWord.Visible = True
End Sub
thanks MIke
Edited by - DaVBMan on 12/20/2005 8:39:04 AM
UsedRange Function Is Not Working Corectly
when i use the UsedRange function on a sheet that has only cells B24 and G30 occupied the UsedRange returns B9 as the top left and G30. Anyone has any idea?
Code:Sub asdkkf()
A = (Sheet1.UsedRange.Address)
A = Replace(UCase(A), UCase("$"), "")
MsgBox A & "," & ColNumber2
End Sub
Timer Function Not Working With MSComm.Output
Please does anybody know why the two MSComm.Outpout lines don't execute within the do:while ?
StartTime = Timer
Do While Timer < StartTime + 10
Comm1.Output = Chr$(110) & Chr$(80)
Comm1.Output = Chr$(110) & Chr$(90)
Loop
The first one executes after 10 seconds, second line never.
Any help greatly appreciated.
Stange: Still Not Working {passing Variable To Function}
Right guys i had the following piece of code:
Code:
Option Explicit
Private Sub Form_Load()
Dim tyre As String
lblQty = frmFitTyres!cboFitted
lblCarReg = frmFitTyres!txtCarReg
lblDate = frmFitTyres!txtDate
lblInvoiceNumber = frmFitTyres!txtId
getTyreType
getTyrePrice
getCompName
getCompAddress
getPostcode
getTelephone
getNetPrice
getDeductions
priceDeductions
getTotalAndVat
End Sub
Public Function getTyreType() ' Finding out what tyre type the car has.
tblCar.MoveFirst
While Not tblCar.EOF
If tblCar!carReg = frmFitTyres!txtCarReg Then
lblType = tblCar!Type
End If
tblCar.MoveNext
Wend
End Function
And it worked fine,
I got told that i needed to pass it variable and declare variables so i edited it to this:
Code:
Option Explicit
Private Sub Form_Load()
Dim tType As String
Dim price As String
Dim compName As String
Dim address As String
Dim postcode As String
Dim telephone As String
lblQty = frmFitTyres!cboFitted
lblCarReg = frmFitTyres!txtCarReg
lblDate = frmFitTyres!txtDate
lblInvoiceNumber = frmFitTyres!txtId
lblType = tType
lblPerTyre = price
compName = lblCompName
address = lblAddress
postcode = lblPostcode
telephone = lblTelephone
getTyreType (tType)
getTyrePrice (price)
getCompName (compName)
getCompAddress (address)
getPostcode (postcode)
getTelephone (telephone)
getNetPrice
getDeductions
priceDeductions
getTotalAndVat
End Sub
Public Function getTyreType(tType As String) ' Finding out what tyre type the car has
tblCar.MoveFirst
While Not tblCar.EOF
If tblCar!carReg = frmFitTyres!txtCarReg Then
tType = tblCar!Type
End If
tblCar.MoveNext
Wend
End Function
And now it doesnt work
So any ideas??
Function For 30-day Trial Period Not Working Correctly. [SOLVED]
VB Code:
Private Sub CheckTrialTime() Dim StartDate As Date Dim EndDate As Date Dim DaysLeft As Integer On Error GoTo SetTrialProperties DaysLeft = Format$(days360(StartDate, EndDate), "##") & " day(s)" MsgBox "You have " & DaysLeft & " days left in your trial.", vbInformation, "Trial version" Exit SubSetTrialProperties: Set Win32Script = CreateObject("WScript.Shell") StartDate = Now EndDate = Now + 30 Win32Script.RegWrite "HKEY_LOCAL_MACHINESOFTWARESparkFTPMain SettingsTrial Begin Date", StartDate Win32Script.RegWrite "HKEY_LOCAL_MACHINESOFTWARESparkFTPMain SettingsTrial End Date", EndDate Set Win32Script = Nothing Resume NextEnd Sub Private Function days360(dt1 As Date, dt2 As Date) As Long Dim z1 As Long, z2 As Long Dim d1 As Long, d2 As Long Dim m1 As Long, m2 As Long Dim y1 As Long, y2 As Long d1 = Day(dt1) m1 = Month(dt1) y1 = Year(dt1) d2 = Day(dt2) m2 = Month(dt2) y2 = Year(dt2) If d1 = 31 Then z1 = 30 Else z1 = d1 End If If d2 = 31 And d1 >= 30 Then z2 = 30 Else z2 = d2 End If days360 = (y2 - y1) * 360 + (m2 - m1) * 30 + (z2 - z1)End Function
This outputs the correct starting and ending dates, but outputs "You have 0 days left in your trial." inside the message box. What's wrong?
Access 97 Function Calls From Events Stop Working.
Hi Folks
I have a very odd one
I have an Access 97 MDB application. It has all been working fine for over a year - upwards of 10 users.
Suddenly one user starts getting errors.
On investigating I find that event procedures and calls from code are working fine.
What is not working is calls to functions directly from events. They give the "Bloggs.MDB can't find the Macro or Function blah blah blah" as if the name was misspelt. (It is not !) Every other user is working fine. I have got a fresh copy of the mdb. I have recompiled the modules the database on the machine in question.
Then I notice his Access is SP1 - Putting on SP2 fixes everything - he is fine - it all works - until he restarted next morning when the problem came back.
I have tried a noddy database written from scratch on his system and it shows the same faults - seems like it is Access that has the problem not the MDB.
If it is relevant he is using Windows ME - everyone else has Windows 98 I think.
HELP PLEASE!!!
Ian J
SQL Function "Round" Is Not Working In VB6.0
Hi Every Body,
I'm new to VB6.0 ,It 'll b handy if anyone suggest me the solution to this problem.
The Query "Select round(<<ColumnName>>,2) from <<tableName>>"
is working fine in Access but when i tried to run this query in VB,
it throws an exception as "Undefined function round in expression".
Kindly do the needful to solve this problem.
Thanks in advance.
|