Lod Posted June 17, 2009 at 07:26 PM Report Share #273167 Posted June 17, 2009 at 07:26 PM Estou com um erro no registo quando estou a por daods. Public Class form2 Structure albuns Dim titulo As String Dim nrfaixas As String End Structure Structure codigo Dim codalb As String End Structure Dim codig As codigo Dim album As albuns Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblnrfaixas.Click End Sub Private Sub btnguardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnguardar.Click Dim pos As Integer = 2 album.titulo = Me.txttitalbum.Text album.nrfaixas = Me.txtnrfaixas.Text FileOpen(1, "C:\Users\Rafael Santos\Desktop\Desktop\Rafael\programinhas\gestmedia\gestmedia\bin\Debug\albuns.txt", OpenMode.Random, OpenAccess.Write, , Len(album)) FilePut(1, album.titulo, pos) 'AQUI que me aparece sempre o erro, diz o seguinte "Comprimento de registo incorrecto.", penso que seja por causa dos espaços na string pos = pos + 1 FilePut(1, album.nrfaixas, pos) FileClose(1) End Sub Private Sub Btnvoltar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvoltar.Click Close() End Sub Private Sub form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim codigoalbum, apont As Integer If My.Computer.FileSystem.FileExists("C:\Users\Rafael Santos\Desktop\Desktop\Rafael\programinhas\gestmedia\gestmedia\bin\Debug\codalbum.txt") Then FileOpen(2, "C:\Users\Rafael Santos\Desktop\Desktop\Rafael\programinhas\gestmedia\gestmedia\bin\Debug\codalbum.txt", OpenMode.Random, OpenAccess.ReadWrite, , 5) While Not EOF(2) apont = apont + 1 FileGet(2, codig.codalb, apont) codigoalbum = codig.codalb End While codigoalbum = codigoalbum + 1 codig.codalb = codigoalbum FilePut(2, codig.codalb, apont + 1) txtcodeq.Text = codigoalbum apont = 0 FileClose(2) Else FileOpen(2, "C:\Users\Rafael Santos\Desktop\Desktop\Rafael\programinhas\gestmedia\gestmedia\bin\Debug\codalbum.txt", OpenMode.Random, OpenAccess.Write, , 5) codig.codalb = 1 FilePut(2, codig.codalb, 1) txtcodeq.Text = codig.codalb FileClose(2) End If End Sub End Class Link to comment Share on other sites More sharing options...
ribeiro55 Posted June 17, 2009 at 07:56 PM Report Share #273170 Posted June 17, 2009 at 07:56 PM Abriu a época de caça? :nono1: Convém dares indicação de que erro e de onde ele é disparado... Já viste a extensão desse código? EDIT: LOL, só agora vi o comment no bloco. Sorry Desconheço FilePut. Já consideraste StreamWriters/Readers? De qualquer maneira, se achas que é por espaços, usa album.titulo.Trim para remover os leading spaces. Não tenho o VB por aqui, assim por alto, o que faz o FilePut? Para ver se te posso ajudar melhor. Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now