Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




ADO CommandText Max Length


VB6 and MS Access

When I create a command such as


Code:
Dim comUpdate As ADODB.Command
Set comUpdate = New ADODB.Command

With fgdWindow(intWdwNum)
strSQL = "UPDATE Windows SET " & _
"Description = '" & .TextMatrix(1, 1) & "', " & _
"JambDepth = '" & .TextMatrix(1, 4) & "', " & _
"ExtSurround = '" & .TextMatrix(1, 5) & "', " & _
"IntSurround = '" & .TextMatrix(1, 6) & "', " & _
"GlassPanes = '" & .TextMatrix(1, 7) & "', " & _
"GlassOption = '" & .TextMatrix(1, 8) & "', " & _
"GlassTint = '" & .TextMatrix(1, 9) & "', " & _
"Quantity = " & .TextMatrix(1, 10) & ", " & _
"Cost = " & CCur(fgdWindowA(intWdwNum).TextMatrix(1, 11)) & ", " & _
"Price = " & CCur(fgdWindowA(intWdwNum).TextMatrix(1, 12)) & _
" WHERE (QuoteID = " & mintQuoteNum & ") AND (WindowNum = " & _
intWdwNum & ")"
End With

With comUpdate
.ActiveConnection = cnWindowWonders
.CommandText = strSQL
.Execute
End With

Set comUpdate = Nothing
Is there a maximum length CommandText can be?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Max Length Of Commandtext?
I usually only need to do searches to find the answers I need. This forum is a wealth of knowledge and I am sure there are plenty of other lurkers that stop by to check out your wonderful home. Thanks for all of the help you have provided that you do not know about.

Anyway, I could not find a good search term to resolve the problem I am having.

Is there a maximum string size that you can move to CommandText of ADODB (sql server)? I am trying to execute an insert that fails with the error:
Code:Unclosed quotation mark before the character string ''.

Code:Set cmdInsert = New ADODB.Command
Set cmdInsert.ActiveConnection = cnTarget

This insert works if I cut and paste into query analyzer, but fails in VB.

Code:INSERT INTO ACCOUNT_APPRL_YEAR( APPRAISAL_YR, ACCOUNT_NUM, ECONOMIC_UNIT_ID, DIVISION_CD, REGION_CD, NBHD_AREA_CD, NBHD_CD, GIS_PARCEL_ID, ROUTE_CD, ACCOUNT_NAME, PRIMARY_IND, EMPLOYEE_ID, LMA_CD, MAPSCO_BOOK_CD, MAPSCO_PAGE_CD, MAPSCO_GRID, MBL_HOME_PARK_ID, PARCEL_ID, FREEZE_CD, SELECTED_IND, CHECKED_OUT_IND, COMM_ACCOUNT_NUM, ROUTING_SEQ_NUM, LAND_VAL, LAST_APPRAISAL_YR, APPRAISAL_METH_CD, TOT_VAL, APPRAISAL_DT, APPRAISER_ID, PREV_YR_RLLOVR_IND, RECEIVED_DT, RENDERED_VAL, RECEIVED_EMPL_ID, TOT_CONTRIB_AMT, CTB_AMT_OVRRD_IND, OVERRIDE_EMPL_ID, P_BLDG_CLASS_CD, P_BUS_TYP_CD, P_IMA_CD, CITY_JURIS_CD, COUNTY_JURIS_CD, ISD_JURIS_CD, SPDT_JURIS_CD, HOSPITAL_JURIS_CD, COLLEGE_JURIS_CD, ACCOUNT_TYP_CD, CALC_YR, P_SPTD_CD, PREV_REVAL_YR, PREV_MTK_VAL, PRV_MKT_OVRD_IND, HS_CAPPED_DIFF, CITY_TAXABLE_VAL, CNTY_TAXABLE_VAL, ISD_TAXABLE_VAL, HOSP_TAXABLE_VAL, COLL_TAXABLE_VAL, SPEC_TAXABLE_VAL, CITY_SPLIT_PCT, CNTY_SPLIT_PCT, ISD_SPLIT_PCT, HOSP_SPLIT_PCT, COLL_SPLIT_PCT, SPEC_SPLIT_PCT, JAN1_OWNER_NAME, JAN1_OWNER_NAME2, SEND_AG_LTR_CDX, SEND_HS_LTR_CDX, SEND_O65_LTR_CDX, MAILING_NUMBER, HS_EXEM_LTR, EXTRNL_CITY_ACCT, EXTRNL_CNTY_ACCT, LST_UPDT_EMPL_ID, LST_UPDT_TS, POST_FLG, LST_ACCT_UPDT_ID, LST_ACCT_UPDT_TS, STATUS_CD, REVOKE_EFF_YR, REVOKE_EXP_YR, REVOKE_HS_CDX, REVOKE_OVR65_CDX, REVOKE_OVR55_CDX, REVOKE_DISABLE_CDX, REVOKE_VET_CDX, RD_QUESTION_CDX, SEND_HS_YR, CHK_HS_CDX, RENOTIFY_IND) Values ( 2005, '00000224122000000', 0, 1, 3, 1, 1, '00000224122000000', 0, '9', 'N', '11', 0, 1, 69, 'J', 0, 0, 0, 'N', 'N', '21', 0, 4950, 2001, 1, 13070, '12/22/2003 4:11:41 PM', '28', 'N', '12/22/2003 4:11:41 PM', 0, '32', 0, 'N', '35', 2, 0, 0, 12, 2, 2, 0, 1, 1, 1, 2001, 1, 1998, 0, '50', 0, 13070, 13070, 13070, 13070, 13070, 0, 0, 0, 0, 0, 0, 0, 'BASS CAROLYN ET AL', '65', 'P', 'P', '68', '69', '70', '000261800001400', '00000224122000000', 'ENTR', '12/22/2003 4:11:41 PM', '75', 'BATCH', '12/22/2003 4:11:41 PM', 0, 1000, 9999, '81', '82', '83', '84', '85', '86', 0, '88', ' ')


My next step is probably a stored procedure...

CommandText
This is my problem:

Assuming this is my MDB file and their records.
==============================================

Employee
============================
EmployeeNo EmployeeName
============================
HDM23860 Mead Lou
HDM23861 Gou Li
============================

EmployeeData
=======================================
EmployeeNo Date Salary
=======================================
HDM23860 10/22/02 250.00
HDM23861 10/22/02 280.00
HDM23860 10/23/02 0.00
HDM23861 10/23/02 200.00
HDM23860 10/24/02 250.00
HDM23861 10/24/02 280.00
HDM23860 10/25/02 250.00
HDM23861 10/25/02 170.00
HDM23860 10/26/02 125.00
HDM23861 10/26/02 280.00
=======================================

In VB6, I add DataEnvironment. Using Microsoft Jet 4.0 OLE DB Provider.
I add a Command1 and the CommandText is "Select * from Employee"
In Command1, I add a Child Command and the CommandText is "Select * from EmployeeData"

My question is, Is it possible to display the record in EmployeeData from 10/22/02 to 10/24/02?

The output I want is something like this:

HDM23860 Mead Lou
==============================================
HDM23860 10/22/02 250.00
HDM23860 10/23/02 0.00
HDM23860 10/24/02 250.00

HDM23861 Gou Li
==============================================
HDM23861 10/22/02 280.00
HDM23861 10/23/02 200.00
HDM23861 10/24/02 280.00


Marivic reply me like this:

Add it to your commandtext.

commandtext="Select * from EmployeeData WHERE Date>10/22/02 AND Date<10/24/02"

I try the code:

'This code work
DataEnvironment1.Commands(1).Commandtext="Select * from Employee"
DataEnVironment1.rsCommand1.Requery

'But I encounter an error with this code:
DataEnvironment1.Commands(2).CommandText="Select * from EmployeeData WHERE Date>10/22/02 AND Date<10/24/02"
DataEnvironment1.rscommand2.Requery

What is the best thing to do?

Commandtext Limitations
Dear All
I am using recordset having query in commandtext property - my problem is that the query is longer then 255 chars and the commandtext property trim it to 255 chars altough the query string is longer then 255 chars.
Thanks alot

Commandtext And 2 Where Statemenst
My select statement has 2 where clauses for the same column. itworks if I use 1 clause but not 2. If I just use Cable Repair it works if I try where Department=In('Cable Repair','RSSG') I get a run time debug error
[code]

Dim ExportCVfile As String
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
Set cmd = New ADODB.Command



Dim freetmpnum As Integer
Dim linestring As String



With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=S:RCSBU 01RESP 2305DEPT 210Real TimeReporting blIDPCommon.xls;" & _
"Extended Properties=Excel 8.0;"
.Open
End With



Set cmd.ActiveConnection = cn

cmd.CommandText = "SELECT * FROM [Input_Data$] where Department=In('Cable Repair','RSSG') and Active='Yes'"

reportingsDate = Sheet1.Range("L1").Value
reportingeDate = Sheet1.Range("L1").Value

For incDate = reportingsDate To reportingeDate


Set rs = cmd.Execute



[/code]

Commandtext Error Handling
hi guys! asside of putting an error traper " onerror resume next" can you guys please help me to trap error in this code:

Code:
Private Sub Command2_Click()

'connection string
Set Cn = New ADODB.Connection
Cn.ConnectionString = "provider=microsoft.jet.oledb.4.0;persist security info = false;data source = c:my documents hesisdata.mdb"
Cn.Open

Set Cmd = New ADODB.Command

With Cmd

.ActiveConnection = Cn
.CommandType = adCmdText
'SQL to delete record by year. single quote is removed because data is a number
.CommandText = "delete from Table1 where Year = " & Text1.Text & ""
.Execute
Text1.Text = "0"
MsgBox "Record deleted successfully! ", vbExclamation, "Delete"

End With
what i want is to trace wheather the record is exuisting or not...

DataEnvironment CommandText Like Syntax!!!!!
Good afternoon from raining Italy...

I just want to select some rows in which a text field contains
a certain word, but SQL syntax of the Dataenvironment Command it's wrong!!!

Could you help me?

ex.

SELECT Items.* FROM Items
WHERE Items.Description LIKE '*?*';


Thanksssss!

How To: Change The CommandText In DED At Runtime
I want to print a report from a query result based on two fields. The fields are named "Trans_Date" and "Date_Encoded" and are represented by checkboxes in my form.

If only Trans_Date has the Check property set to True, then my SQL string would be,

SELECT * FROM tblTransactions WHERE Trans_Date BETWEEN ? AND ?

If only Date_Encoded has the Check property set to True, then my SQL string would be,

SELECT * FROM tblTransactions WHERE Date_Encoded BETWEEN ? AND ?

If both has the Check property set to True, then my SLQ string would be,

SELECT * FROM tblTransactions WHERE (Trans_Date BETWEEN ? AND ?) OR (Date_Encoded BETWEEN ? AND ?)

Questions:
1. How do i toggle with these queries in the Command object at the DED? I have tried putting code in the Print_Click button event like,

With Command
    .ActiveConnection= My Connection
    .CommandText=strSQL_based_above
    .CommandType=adCmdText
    .Execute
End With

deReports.Transaction Date1, Date2
rptTransactions.Show

2. How do i create a parameter that is optional


Am i doing the right way towards achieving the desired result? I Hope you could share to me a better way.


Using Datareport CommandText Property
Follow programmers, any ideas would be very very appreciated

I have a dataenvironment with connection already established. This work good.

My question is, can I add a command (ie "cmdGeneric") without any specifications from where it needs to retrieve data (table, sql) only with the property CommandType set to adCmdText?

What I want to do is to run my application and during runtime, I want to set the CommandText to either update, delete, insert any of my tables. I'd like to use this because I can easily end up having up to eight differents command.

Thanks

Changing The CommandText Of A Command
Is there anyway to change the CommandText of a child command in the dataenvironment? Everytime I try, VB gives me an error....any help is greatly appreciated.

Using Isnull Function Into Commandtext Of Adodb
can anyone tell me how I can use isnull function into commandtext?
I use this code but it isnt correct:

Code:
cmd.CommandText = "select khaneh_behdasht from markaz where Not IsNull(markaz.khaneh_behdasht)"

Changing DataEnvironment CommandText At Runtime
I have built a report template at design time with its datamember set to a DE command that is structured with a grouping on a specified field. For reference, the command name is "cmBalPerBranch_Grouping".

At runtime, using different table but with the same structure with the orig table (field names,types and the no. of fields), I have setup a SQL statement (identical to the orig statement, but using the other table) and attempted to change the commandtext using:
CODEde.Commands("cmBalPerBranch_Grouping").CommandText=strSQL

VB/Oracle Ado Recordset Using Commandtext Object
hi
how can i open a recordset to add data with recordset.addnew function.

where i use oracle database and commandtext object to execute a oracle pl/sql package.procedure.

here is my source:

Dim cmd As ADODB.Command


    Set cmd = New ADODB.Command
    Set cmd.ActiveConnection =MyCon
    
    cmd.CommandText = "{CALL package_ABC.sp_Cus_PROC}" 'here package.sp_Cus_proc is a procedure in a package.
' adoRsVchrParn.CursorType = adOpenKeyset
' adoRsVchrParn.LockType = adLockOptimistic
    Set adoRs = cmd.Execute
    Set cmd = Nothing

with adors
               .addnew
                !id=txtid
                !name=txtname
               .update
end with

here i get an error no.3251 Object or provider is not capable of performing requested operation.

here the adors recordset is opening with default cursortype and locktype.

how can i change? or where can i mention? the cursortype and locktype to perform .addnew function?

with thanks.



Edited by - shaibal on 9/11/2002 4:02:54 AM

DataEnvironment.Commands(...).CommandText Can Only Be Changed Once
I have a DataEnvironment who has commands that DataReports use. Each DataReport has only one Command associated with it, and vice versa.

I want to add some flexibility to the reports tool by allowing ordering, chosen before the report is run, from a combobox. When an ORDER BY is chosen by the user, the DataEnvironment.Commands("commandName").COmmandText is updated to a new SQL statement

I find, that i can change the commandtext, then show the report and it does indeed reflect my chosen ordering. I close the report, and then i find that changing the command texts further times, and showing the report, does not change the report; it still uses the recordset ordered from the first run of the report

how do i reset the report so that it gets a fresh recordset each time?

the advice here: http://forums.devshed.com/t60380/s.html
did not seem to work

when i nip into the code for the DE, there is a rsFullStockList property (the rs for the command for which i am changing the SQL), and i can insert code itno any of the following.. has anyone any recommendations?

Code:

Private Sub rsfullStockList_EndOfRecordset(fMoreData As Boolean, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_FetchComplete(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_FetchProgress(ByVal Progress As Long, ByVal MaxProgress As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_FieldChangeComplete(ByVal cFields As Long, ByVal Fields As Variant, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_RecordChangeComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_RecordsetChangeComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_WillChangeField(ByVal cFields As Long, ByVal Fields As Variant, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_WillChangeRecordset(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Private Sub rsfullStockList_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

End Sub

Data Environment - DECommand - Different CommandText Queries
Hi All,

I have a Estate Agency Program which has two features specific to this request to help. These are to:

- View a Single property using its Reference Number
- Search for Propertys based on area and price

Now, I have Adodc control on my form which works fine for viewing on screen and works fine with the SQL queries my code generates based on the options the users selects.

My next task was to create a DataEnvironment so I could print out a report with the same data as onscreen.

I created the following:

denEstate - Data Environment
DBConnection - DEConnection connected to the database at design time
Estate - DECommand inplemented using groups to display the properties grouped by property number

I've tried two methods:

Firstly I set the DECommand to be a SQL statement and left CommandText blank.

In the module in my main form which loads the printing function is used the following code:

Code:
Private Sub PrintProperty_Click()

    denEstate.Commands("Estate").CommandText = printsql
    rptPrint.Show vbModal
    
End Sub


When I run this code I get the following:

"Run-time error 5, Invalid Procedural call or argument"

The other method I tried was to set the commandText of the DECommand Estate to be:

Code:Select * FROM properties WHERE ?

I then specified the parameter "query".

Now in the printing code I executed

Code:
denEstate.Estate_Grouping (printsql)
rptPrint.Show vbModal


This time I get no errors, but all records are shown on screen as if it totally ignored by parameter to be added to the query and executed:

Select * From properties WHERE

As an example of printsql, in one case it will be equal to "[Property Number]=51" which should build the following SQL query:

Select * From properties WHERE [Property Number]=51

----

But it doesn't. Can anyone help?? Any ideas to how I can achieve this. Is their anyway to get the data environment to use the recordset of the ADODC control on the main form which obviously is displaying the correct records at the time of printing!

Cheers

Jaapgriff

Data Environment Command Have Not [.commandtext Protperty]?
example:

idefined 1 data environment + command on it with name [comPersonel]
when i try to change its SQL statement at run time is get error
cause DataEnvironment1.comPersonel have not .commandtext property?why?

  With DataEnvironment1.comPersonel
     .CommandText = "SELECT * FROM Personel"
  End With



can any body send me sample project that can change this sql statement runtim?


 

Data Report:Setting CommandText Of DataEnvironment With Parameters
Hi,
I'm currently using the Data Report facility of VB6 and am quite new to it.
Wondering how I can set the commandText of the command facility under the dataenvironment with variables I have passed into the report?

My commandText string of the command is like this:
SELECT * FROM tblcustomersection where RequestNo > '" & requestNoStart & "' and RequestNo < '" & requestNoEnd & "' order by RequestNo

requestNoStart and requestNoEnd are variables I've passed into the generated report but unfortunatley these don't seem to be picked up by the commandText.
Hope I'm doing something basic wrong.
Thanks.

How Do I Make This Midi Code Play For The Length Of The Song, Like How2 Detect Length
I got his code off the net from somewhere and i am playing with it

It has a set length on how long to play the midi file for.

which is 15, im not sure how many seconds this is.

heres the code and theres alot of it so..

-------------------

Code:
Public Sub PlayMidi()
Dim sFile As String
Dim sShortFile As String * 67
Dim lResult As Integer
Dim sError As String * 255
Dim sCommand As String

lResult = GetShortPathName(gsMidiFile, sShortFile, _
Len(sShortFile))
gsMidiFile = Left$(sShortFile, lResult)

If Not gbPlaying Then
'Make the call to open the midi file and assign
'it an alias
lResult = mciSendString("open " & gsMidiFile & " type sequencer", ByVal 0&, 0, gHW) '0&) 'AddressOf MidiNotify)

'Check to see if there was an error
If lResult Then
lResult = mciGetErrorString(lResult, sError, 255)
Debug.Print "open: " & CStr(lResult) & ": " & sError
Exit Sub
End If
End If

'Make the call to start playing the midi
If glFrom = 0 And glTo = 0 Then
sCommand = "play " & gsMidiFile & " from 0 notify"
Else
sCommand = "play " & gsMidiFile & " from " & CStr(glFrom) & " to " & CStr(glTo) & " notify"
End If
lResult = mciSendString(sCommand, ByVal 0&, 0, gHW)

'Check to see if there were any errors
If lResult Then
lResult = mciGetErrorString(lResult, sError, 255)
Debug.Print "play: " & CStr(lResult) & ": " & sError
Else
gbPlaying = True
End If

End Sub


-----------------------------------------------------------------------
the glto and glfrom are from where to play the midi from start to finish. heres the other section where u input the glto and glfrom
--------------------------------------------------------------------

Public Sub PlayMidi()
gHW = Me.hWnd
gsMidiFile = App.Path & "mcitest.mid"
gbRepeat = True 'Set to true if you want it to repeat

glFrom = 0
glTo = 15 'Will play for a couple of seconds


CloseMidi
UnHook
DoEvents

PlayMidi
Hook

End Sub
----------------------------------------------
i want to have glTo= Lenght of midi file
not some set number...
how would i do this?

How To Get From Integer Length 3 To String Length 5
Hey, I've got the next problem:

A message is delivered to me by MQSeries, from this message I'm able to retreive a client number. This client number is an integer can be anything from 1 to 99999. My program needs to work with a String. fe. If client number 444 is deliverd my program has to handle this as 00444. Does anybody now how to mannage this.

Extra zero's have to be added in case the integer is not 5 long. The number of zero's can also very.

Please help.

HTMLFormElement.Item("length") Overwrites The HTMLFormElement.length
I'm using the WebBrowser control in a VB program and need to analyze the page a bit.

The WebBrowser.Document.Forms(i).Length normaly returns the number of fields in the form, but as soon as there is a field named "length" (case doesn't matter of course) in the form HTMLFormElement.Length starts returning the HTMLInputElement instead of the number of fields.

Is there any way to either prevent this or at least to get the number of fields? Short of looping and testing when the HTMLFormElement(index) starts returning Nothing?

Thanks, Jenda

P.S.: First I though that this is the usual misbehaviour of Collections in VB (I learned to expect the least sane behaviour from VB), but it doesn't seem to be that way. I guess this is just a "feature" of the WebBrowser.Document.* objects.

P.P.S.: No I can't prevent people from using fields named "length" or "Length" or whatever.

Length
Hello everyone! Using the following formula:

Open Path For Output As #20
Print #20, Text1.Text
Close #20

It crashes if I try and save a file over about 35 KB. Do you know of a better method of saving a DOS text file? Thanks!

<font color=red>ALPHANUMERIC</font color=red>

Getting Length
i am creating a program which returns a list of the filenames in a folder and some other relevant info such as extension, type, size etc.

Now if the files in a folder, happens to be mp3s, is it possible that somehow i will return the length of the mp3 as well please ?

Thank You

P.S. I am getting the above info, by referencing the Miscrosoft Scripting.

URL Length...
Do URLs have an upper size limit before they stop working?

I am trying to send data to a server using the
ServerXMLHTTP40 object within... it's a bmp image so is quite quite big.

The webserver is returning the following message :


<html><head><title>Bad Request</title></head><body><h1>HTTP/1.1 400 Bad Request</h1></body></html>


(the image is encoded in the URL- it's being passed to an ASP page...)

Length?
Hi ok I have 2 text boxes right next to each other and I was wondering if theres a way to find out the length of them both together? Well thanks I appreciate it

Set Length
When I change a character to ascii, i want it to always be three digits, ex: A = 65 = I want "065", is there any easy function or will I need to do it my own way?

Length Of MP3
Hi,
i want to create a program that lists all my mp3's and their length (minutes + seconds) .
No problem to list the mp3's, there all in one directory, and the filesystemobject knows how to handle this, but how can i get the length of the song?

Can i use a mediaplayer ocx or winamp component or something? Are there easier ways?

Greetz !

Length
How can I change the length of a string at runtime?

Mp3 Length
How can I know the duration of a media file?
I'm using the media player control.

[Edited by dekelc on 10-19-2000 at 11:23 PM]

Allow Zero Length
How can you change the allow zero length property of a field using an sql query?

Tab Length
Hi

In my chat program i need to use vbTab to seperate text headers (users names), from their chat messages in a text display. My problem is that vbTab isnt long enough, it dosnt create a big enough gap. I cant use spaces for this because if two headers were not the same length, then the message starts would not be lined up right. The vbTab also has this problem if the header is to long. Is there a way to increase the size of the tab my program uses without affecting the system settings? Any other ideas to solve this problem would be helpful, i feel i have tried everything i can think of so i dont know where to go now... below is a representation of the problems.

Code:
Short: Shortnames chat text
Long Name: Long names chat text


But i need to to be more like this...
Code:
Short:     Shortnames chat text
Long Name: Long names chat text


Also i tried using two tabs but then, it is too long

Thanks

Mp3 Length
I am kindsa stuck on this I'm trying to get the length of a song but it isn't working to well and i don't have that much knowledge in math

Code:
Private Sub Form_Load()
  Dim time() As String

  MediaPlayer1.FileName = "D:Cake2. Fashion Nugget1. Frank Sinatra.mp3"
  time = Split(MediaPlayer1.Duration / 60, ".")
  Me.Caption = time(0) & "." & Left(time(1), 2)
  If MediaPlayer1.FileName <> "" Then MediaPlayer1.AutoStart = True
End Sub


can anyone help me?



Edited by - CodeGeek on 4/11/2003 2:45:56 AM

How To, Length Of Image Bar.
I have a jpg image, that has multiple bars on it with different lengths, I am trying to determine the length of the bar or the 'filled' area.

I want to write a little application that can look at the entire image with the bars, and change the bars to values.

The bars are a constant width (total bar size), and there a constant height.

Wich api would I use or how would I go about getting the length of the filled in area?

I thought there might already be code out there to do this, but I can't find any, and I don't know where or how to begin.

Thanks ahead of time.

Getting String Length
i have a binary file with has lots of strings,i could determine the offset for each string but each string is different in length,is there any easy way to get the length automatically ,the char next to each string end is 0D0Ah or 00h,i know this might come in handy .btw i use " Get #1,[offset],[length]" statement


thanks for the help

Rec Length Limit Of 32k...
Hi,
Trying to open some files in chunks, process the chunk and then open the next chunk.

The way my data is stored, the best way to process it requires opening a 'line' of data at a time.

Unfortunately this 'line' is sometimes bigger than the 32k limit on the reclength parameter of the Open file command and I get an Overflow message when I try to open the file.

Is there any easy workaround / or alternative that can be used to allow processing of the chunk at one time?

When I opened the COMPLETE file in one go, I did not have such a problem, but required a lot of memory! So I thought processing in chunks would be the best solution....

Any ideas would be great, thanks,

pete

Phys Length From Len()
I am trying to set the widths of a listbox to match the text within perfectly, however i dont know how to calculate the physical length of a string (in in, cm, or pt) given the string length (Len()) and its font size.

any ideas?

ie) 8pt font, len(string)=100, so columnwidth=150 pt.

thanks, jeff

Length Of A String
Does anybody knows how to calculate the lenght of a string with a specific font ?

I know how to calculate the number of characters :

var = len(String)

But I have no idea about calculating the length with a font. Can anyboby help me ?

Thanks in advance,

fojek

Text Length
On a MS Access 2000 form, how can I determine the length (in twips, or otherwise) of the text in a text box? I have done this in reports by setting the fontname, size, etc. and using textwidth, but can I do something similar with a form?

Input Box Length
Is it possible to only allow 8 characters to be written into the inputbox as a form of validation.
The reason being that if the number they input is to big it crashes my program..

String Length
Hi !

I just don't remember the command line that gives the length of a string and I can't find it with VB help. Can anyone tell me ?

thanks for your help

'Bad Record Length'
Hello Code Gurus!

In the last year, I've evolved into an Excel "super freak" at work and spend most of my time now in the VB Editor rather than the worksheets. I'm self taught, so every now and then I discover a simple solution to things I'm trying to do. I'm hoping the solution to this is something simple that has slipped by me. Now, Here goes:

I have an attendance tracking sheet that reads records ("AttendInfo") from a Random Access file on a shared network drive. Here's the setup of that record type:


Code:
Type AttendInfo
complete As String * 1 '(0 = Incomplete, 1 = Complete)
occurrencedate As Date ' 8 bytes 'Initial occurrence
associatename As String * 20 'Associate's Name
supervisorname As String * 20 'Associate's Supervisor
occurrencetype As String * 1 '(0=UNPL, 1=TRDY/EO, 2=UNPLU, 3=TDEOU, 4=ADHR)
suggestion As String * 1 '(0=VERBAL, 1=WRITTEN, 2=FINAL, 3=TERM)
status As String * 15 'Status of notification
lastupdate As Date ' 8 bytes 'Date of last update
firstfollowup As Date ' 8 bytes 'Date of first update
completiondate As Date ' 8 bytes 'Date completed
notes As String * 128 'Explanation area for "mistakes" if needed
operator As String * 15 'Notes which Network User modified the record last
End Type

The read/write routines run great 95% of the time, but every now and then I get a 'Bad Record Length' error that won't go away once it pops up, no matter how many times I stop/reset and try to re-run the macro. The Random Access file is perfectly fine, the data being fed to the file is fine, it just gives a 'Bad Record Length.' Now, to fix this, I've found that I must go into the VBE and remove the AttendInfo type completely, reset the program, paste the very same AttendInfo code back, then run it again. Everything will run smoothly after that. Wierd?

I can understand the occasional hiccup when reading & writing thousands of records over the network, but I guess the piece I'm missing is how to error trap that, and fix it or reset the variables so the end user can try the import/export again. As it is now, I have to perform the task manually in VBE with the cut/reset/paste/run. Anyone else experience this, or know how to reset these variables automatically with code? It's driving me nutz! Thx!

Regards,
-Mike

Array Length
Hi everyone,
I simply am going to cut off the first and last character of each string in an array.
So I use this code in VB.NET :

Code:
Dim SStr() As String = Something...

For MyLoop As Integer = 0 To SStr.Length - 1
SStr(MyLoop) = SStr(MyLoop).Substring(1, SStr(MyLoop).Length - 2)
Next
When I wanted to use it in VB 6 also, unfortunately, I forgot some rules in VB6, it's a long time I am not using VB6!

Code:
Dim SStr() As String = Something...

Dim MyLoop As Integer

For MyLoop = 0 To Len(SStr) - 1
SStr(MyLoop) = Mid(SStr(MyLoop), 1, Len(MyLoop) - 1)
Next
I get error, however I wanna know how to get the number of arrays in SStr()?!

Help With Bad Record Length
this is some of the code. When vb gets to fileput it stops and i break it and fileput is higlighted with message bad record length when i right click and go to definition it highlights Dim OneCustomer As CustomerType. Can anyone help this has slowed me down big time. thx in advance.


Private Sub btnFinished_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFinished.Click
Filename = "Customers.dat"
Dim OneCustomer As CustomerType
Dim newform As New frmInterface
OneCustomer.CustomerID = txtCustomerID.Text
OneCustomer.FirstName = txtFirstName.Text
OneCustomer.Surname = txtSurname.Text
OneCustomer.Address = txtAddress.Text
OneCustomer.PostCode = txtPostCode.Text
OneCustomer.TelNo = txtTelNo.Text
FileOpen(1, Filename, OpenMode.Random, , , Len(OneCustomer))
FilePut(1, OneCustomer, NumberOfRecords + 1)
FileClose(1)
NumberOfRecords = NumberOfRecords + 1
newform2.lblNoOfCustomers.Text = NumberOfRecords
newform.Show()


End Sub
Structure CustomerType

<VBFixedString(7)> Public CustomerID As String
Dim FirstName As String
Dim Surname As String
Dim Address As String
Dim PostCode As String
Dim TelNo As String
Dim Discount As Boolean

End Structure

Length Of Variant
i have created a file with two fields of variant data type....

Code:
public type File
Username as variant
password as variant
end type

i am now records to a random file with a record structure as above. when reading from the file and displaying the name field in a combo box, nothing appears, the coding is below....


Code:
dim ID as File
dim counter as integer
dim num as integer

file = app.path & "Users"
open file for random as #1 len = len(ID)
counter = lof(1) / len(ID)
for num = 1 to counter
get#1, , ID
combo1.additem ID.Username
next num
close #1

i cannot see what is wrong with this...........can anyone help......the combo box needs to be populated

the username needs to be variant as there is a check (when adding to the file) to see whether the username already exists.........so it will not work as the additional characters not used in the string would have to replaced with spaces..........e.g. if


Code:
dim username as string * 10

then if a record has a user name "Bob" then when adding the string "Bob " will be checked.............which requires too much coding.

Length Of String
Hi Guys,

I have a problem with the VB6 code below. I am trying to create an encryption and decryption program by converting the ASCII keycodes to alternate characters. I am doint this by adding incremented integer " i " which is used in the for next loop for the Mid command as a kind of psuedo random number.

The problem I have is that when the length of string exceeds 255 the number generated " i " causes an error as the ASCII code set has a maximum of 255 characters.

I am sure there is a simple work around for this but I can not see the wood through the trees at the moment.

I would appreciate any suggestions.

Thanks P

Private Sub EnCmd_Click()

CipherTxt = ""
LS = Len(InText.Text)

For i = 1 To LS
Sentence = Mid(InText.Text, i, 1)
Ascii = Asc(Sentence)
CipherAsc = Ascii + i
If CipherAsc > 255 Then CipherAsc = CipherAsc - 255
CipherTxt = CipherTxt + Chr(CipherAsc)
Next
OuText.Text = CipherTxt


End Sub

Run-Length Compression
Deal all

I have an assignment that I have to submit it after a week and I hope that I can find some one who can help me with it :

The question consist of the following :

Write a program that implement a Run-length compression from file stream that has the following:
1010110
1001100
0010010
0010101
1110011
0000111

1-The program should count the number of lines.
2-The program should count the number of columns(length of the line) .
3-The program should compressed the data in a way the it will detect the position of the zero(0) from to and the output should be similar to this :

22 44 77
23 67
12 45 77
12 44 66
45
14


That mean that the zero has started from position two and end on position two and also has started from position four and ended on position four an so on up to the end of the file


I have managed to solve the first two question throw function that return the number of line and the number of columns.

But I need some one to help me with the part three

So please could any one help me with it as soon as possible.

Length Of Textbox
how can i find the lenght of the characters in textbox1?

something like

text1.length ?

Record Length Vs. CSV
This all OUGHT to be a lot simpler than it currently looks...

Perhaps my quirky CommBASIC setup just doesn't have the capacity to read from .csv files, or perhaps I'm overstating the complexity of this "reclen" deal. I have a .csv file, let's say it contains the values Chicago,Edmonton,Boston,Toronto,Washington. I want my script to open the file and read each element into a listbox. There's a Get statement, which only works for Binary or Random modes, and in Binary I'm supposed to know the byte position of the data I want (that won't do), and in Random I have to specify a "record length." These are strings of varying length, I cain't specify a single record length (even if they were identical-length strings, I betcha there's byte-type stuff and ASCII type stuff that reclength goes by as well). There's an Input Statement, which it says reads data from a file sequentially (how much data, and sequenced according to what?). LineInput comes close but I'm using commas, not lines....

grrrr....How the heck do I just read, say, five comma-separated walues from a freakin blamed .csv file and store them in five named variables in my program!!?!?

Cell Length
Hi
Is there a way to find out how many characters can fit in a cell before it would wrap?

Thanks
D.

String Length
Hi there,

How can I find the length of a String in points not in digits?

len(string) return the length in digits !

thanx in advance!

Metev

Listbox Length
I have embedded a listbox within a datagrid to give my users options for populating the fields. This works great, but I am running into a problem with my list boxes running off the form window. Is there a way to set the length of the dropdown menu? Or can I just set it to stop at the end of the form? I appreciate any help someone can provide!

Thanks!

Copyright 2005-08 www.BigResource.com, All rights reserved