Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
  • Avatar do usuário
Avatar do usuário
Por JeanHard
Posts Avatar
#5020
Boas amigos.

No código abaixo, como faço para o mesmo me dar o maior valor da primeira coluna do listview.

Sub Maior()
Dim ip As Integer
Dim MaxValue As Integer

'(1) refere-se a segunda coluna. Já que a contagem para listview começa com (0)


MaxValue = ListView1.ListItems(1).SubItems(1)

With ListView1


For ip = 1 To .ListItems.Count
If .ListItems(ip).SubItems(1) > MaxValue Then
MaxValue = .ListItems(ip).SubItems(1)
End If
Next ip

End With
Me.Txt_Registro.Value = MaxValue + 1


No aguardo.
Avatar do usuário
Por Startec
Posts Avatar
#5022
Use ListItems.Item que faz ref. a 1ª coluna:
Código: Selecionar todos
Sub Maior()
Dim ip As Integer
Dim MaxValue As Integer

'(1) refere-se a segunda coluna. Já que a contagem para listview começa com (0)


MaxValue = ListView1.ListItems.Item(1)

With ListView1


For ip = 1 To .ListItems.Count
If .ListItems(ip).Text > MaxValue Then
MaxValue = .ListItems(ip).Text
End If
Next ip

End With
Me.Txt_Registro.Value = MaxValue + 1
End Sub
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord